All Projects → jsfehler → Phaser Ui Tools

jsfehler / Phaser Ui Tools

Licence: mit
Functions for creating a UI in Phaser. Rows, columns, viewports, scrollbars, stuff like that.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Phaser Ui Tools

Slither.io Clone
Learn how to make Slither.io with JavaScript and Phaser! This game clones all the core features of Slither.io, including mouse-following controls, snake collisions, food, snake growth, eyes, and more. Progress through each part of the source code with our Slither.io tutorial series.
Stars: ✭ 168 (-10.16%)
Mutual labels:  phaser, phaserjs
Opensc2k
OpenSC2K - An Open Source remake of Sim City 2000 by Maxis
Stars: ✭ 4,753 (+2441.71%)
Mutual labels:  phaser, phaserjs
generator-phaser-browserify
A generator for Phaser using Gulp and Browserify
Stars: ✭ 36 (-80.75%)
Mutual labels:  phaser, phaserjs
Phaser State Transition
State transition plugin for Phaser.js
Stars: ✭ 169 (-9.63%)
Mutual labels:  phaser, phaserjs
Phaser Kinetic Scrolling Plugin
Kinetic Scrolling plugin for Canvas using Phaser Framework
Stars: ✭ 117 (-37.43%)
Mutual labels:  phaser, phaserjs
blocker
🎮 (WIP - phase 3) Multiplayer online game using Phaser + WebSocket (Socket.IO)
Stars: ✭ 48 (-74.33%)
Mutual labels:  phaser, phaserjs
Phaser3 Docs
Phaser 3 Documentation and TypeScript Defs
Stars: ✭ 339 (+81.28%)
Mutual labels:  phaser, phaserjs
craft
Phaser Library with utility chainable functions
Stars: ✭ 27 (-85.56%)
Mutual labels:  phaser, phaserjs
Phaser Node Kit
Rapid Game Development with PhaserJS and Node for Modern Browsers
Stars: ✭ 39 (-79.14%)
Mutual labels:  phaser, phaserjs
Phaser
Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
Stars: ✭ 30,918 (+16433.69%)
Mutual labels:  phaser, phaserjs
floating-scroll
Lightweight jQuery plugin providing floating scrollbar functionality
Stars: ✭ 72 (-61.5%)
Mutual labels:  scrollbar, user-interface
Ion Phaser
A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
Stars: ✭ 152 (-18.72%)
Mutual labels:  phaser, phaserjs
handy-scroll
Handy dependency-free floating scrollbar widget
Stars: ✭ 15 (-91.98%)
Mutual labels:  scrollbar, user-interface
phaser-3-palette-swapping-example
Example of using palette swapping on a spritesheet in Phaser 3.
Stars: ✭ 32 (-82.89%)
Mutual labels:  phaser, phaserjs
phaser-starter
Minimal starter project to get a Phaser game environment up and running with ease.
Stars: ✭ 73 (-60.96%)
Mutual labels:  phaser, phaserjs
Generator Phaser
A yeoman generator for phaser games
Stars: ✭ 255 (+36.36%)
Mutual labels:  phaser, phaserjs
phaser-particle-editor-plugin
This plugin creates particles based on JSON data generated by Phaser Particle Editor
Stars: ✭ 28 (-85.03%)
Mutual labels:  phaser, phaserjs
phaser-ui-comps
Phaser 3 UI Components built by Adobe Animate
Stars: ✭ 60 (-67.91%)
Mutual labels:  phaser, user-interface
Webpack Starter Basic
A simple webpack starter project for your basic modern web development needs.
Stars: ✭ 552 (+195.19%)
Mutual labels:  phaser, phaserjs
Phaser Examples
🎮 Game collections made by Phaser
Stars: ✭ 140 (-25.13%)
Mutual labels:  phaser, phaserjs

Phaser UI Tools

Codacy Badge Build Status

I really wanted a viewport with a scrollbar. Things escalated.

scrollbar

Documentation

https://jsfehler.github.io/phaser-ui-tools/

References

Scrollbar math: http://csdgn.org/article/scrollbar

Getting Started

Using NPM

On the command line, type:

npm i phaser-ui-tools

The objects are now available via import:

import { Column } from 'phaser-ui-tools';

var column = new Column(...)

Adding the file directly to your project

Get phaser-ui-tools.js from the releases and add it to your project's index.html. It should look something like:

<script src="lib/phaser-ui-tools.js"></script>

The objects can now be used directly:

var column = new uiWidgets.Column(...)

The Tools

Text Overlays

TextSprite

A sprite that can have text on top.

Text is added with the setText() method.

var textSprite = new uiWidgets.TextSprite(
    game, x, y, key,
);
textSprite.setText(label, style);
TextButton

A button that can have text on top.

Text is added with the setText() method.

var textButton = new uiWidgets.TextButton(
    game, x, y, key, callback, callbackContext, overKey, outKey, downKey, upKey,
);
textButton.setText(label, style);
Examples
Phaser CE

Header & Buttons | Code

Phaser 3

Header & Buttons | Code

Containers

Column

Columns are Phaser Groups where each child added to the group is placed directly under the previous child. If an object can be a child of a Group, it can likewise be in a Column.

column

var column = new uiWidgets.Column(game, 8, 8);
column.addNode(sprite_a, 8, 8);
column.addNode(sprite_b, 8, 8);
column.addNode(sprite_c, 8, 8);
Row

Rows are Phaser Groups where each child added to the group is placed directly next to the previous child. If an object can be a child of a Group, it can likewise be in a Row.

row

var row = new uiWidgets.Row(game, 8, 8);
row.addNode(sprite_a, 8, 8);
row.addNode(sprite_b, 8, 8);
row.addNode(sprite_c, 8, 8);
Viewport

Viewports are Phaser Groups where the children in the group are only visible if they're within the viewport's area. If an object can be a child of a Group, it can likewise be in a Viewport.

Viewports can be combined with a Scrollbar to create a scrollable display.

Placing a Column or Row inside a Viewport is a simple way to align content.

var viewport = new uiWidgets.Viewport(game, 75, 75, 600, 260);
viewport.addNode(column);

Bars

Scrollbar

Scrollbars are used to move the objects in a Viewport. They must be used with a Viewport. A tweening duration and easing can be specified. This will be triggered when moving the bar.

var scrollbar = new uiWidgets.Scrollbar(
    game,
    viewport,
    true,
    true,
    true,
    trackImage,
    barImage,
    {'duration': 300, 'ease': Phaser.Easing.Quadratic.Out}
);
Examples
Phaser CE

Vertical | Code

Horizontal | Code

Phaser 3

Vertical | Code

Horizontal | Code

ValueBar

Valuebars are like Scrollbars, but instead of moving content, they increase/decrease a number. Valuebars always have a minimum number of 0, but the starting and maximum number can be set. A tweening duration and easing can be specified. This will be triggered when moving the bar.

valuebar

var valuebar = new uiWidgets.ValueBar(
    game,
    {'x': 50, 'y': 10},
    {'step': 1, 'startValue': 0, 'maxValue': 100},
    true,
    false,
    true,
    trackImage,
    barImage,
    {'duration': 100, 'ease': Phaser.Easing.Quadratic.Out}
);
Examples
Phaser CE

ValueBar | Code

Multiple ValueBar inside a Column, with background image and keyboard events | Code

Phaser 3

ValueBar | Code

QuantityBar

QuantityBars do not adjust a value, they get adjusted by a value. The bar grows and shrinks based on a value. They can be used for health bars, stamina bars, etc. A tweening duration and easing can be specified. This will be triggered when moving the bar.

quantitybar

var quantitybar = new uiWidgets.QuantityBar(
    game,
    {'x': 50, 'y': 10},
    {'startValue': 50, 'maxValue': 100},
    false,
    false,
    trackImage,
    barImage,
    {'duration': 400, 'ease': Phaser.Easing.Quadratic.Out}
);
Examples
Phaser CE

QuantityBar | Code

Phaser 3

QuantityBar | Code

Wheel3D

A collection of sprites that are arranged around a three dimensional wheel. The wheel can be adjusted and rotated along the x, y, or z axis.

wheel3D

var wheel = new uiWidgets.Wheel3D(
    game,
    {"x": game.world.centerX - 100, "y": game.world.centerY},
    [sprite1, sprite2, sprite3, sprite4],
    0,
    90,
    "y",
    {"x":0, "y": 0, "z": 0}
);
Examples
Phaser CE

Wheel3D | Code

Phaser 3

Wheel3D | Code

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].