2D HTML5 rendering and layout engine for game development

Overview

Stage

Stage.js is a 2D HTML5 JavaScript library for cross-platform game development, it is lightweight, fast and open-source.

Check out examples and demos!

Install · Usage · Resources · API Doc · Development · License

中文手册

Introduction

Canvas is the graphic component of HTML5 game development, but it only has a drawing API and there is no data model like the DOM to compose your application. You need to manually draw your application and manage rendering cycles to play it. Moreover, mouse events are only available at the entire Canvas level and they also need to be processed manually.

Stage.js provides a DOM-like tree data model to compose your application and internally manages rendering cycles and the drawing of your application. It also processes and distributes mouse and touch events to targeted tree nodes. A Stage.js application consists of a tree of nodes. Each node is pinned (transformed) against its parent and has zero, one or more image textures.

Each rendering cycle consists of ticking and drawing tree nodes. On ticking, nodes adjust themselves to recent updates while on drawing each node transforms according to its pinning and draws its textures.

Rendering is retained and is paused when there is no change.

Example

// Create new app
Stage(function(stage) {

  // Set view box
  stage.viewbox(300, 200);

  // Create an image and append it to stage
  var box = Stage.image('box').appendTo(stage);

  // Align box to center
  box.pin('align', 0.5);

  // On mouse click...
  box.on('click', function(point) {
    // ...tween scale values of this node
    this.tween().ease('bounce').pin({
      scaleX : Math.random() + 0.5,
      scaleY : Math.random() + 0.5
    });
  });
});

// Adding a texture
Stage({
  image : 'sample.png',
  textures : {
    box : { x : 0, y : 0, width : 30, height : 30 }
  }
});

Installation

Download

Latest builds are available in the project releases page.

NPM

npm install stage-js --save

Bower

bower install stage-js --save

Usage

Browser

Include an appropriate build file from dist directory in your HTML page before your application. For example:

<script src="path/to/stage.web.min.js"></script>
<script src="path/to/your-app.js"></script>

Browserify, CommonJS, Node.js

Generally it is preferred to directly include a browser build file in HTML pages, however it is also possible to use CommonJS require instead, for example:

var Stage = require('stage-js/platform/web');

See platform directory for other available modules.

Resources

Introduction to Stage.js by Baljeet Rathi, SitePoint

中文手册 by Villor 紫刃

API Doc

Application

An application is created by passing a callback function to Stage(). The library will load, create and initialize all required components and will then call the provided function with the application root node and display the container which is normally a Canvas element.

// Create and start an application
Stage(function(stage, display) {

  // Set viewbox for stage, see pinning for valid modes
  stage.viewbox(width, height, mode = 'in-pad');

  // Listen to view port resize events
  stage.on('viewport', function(viewport) {
    // `viewport` attributes are `width`, `height` and `ratio`
  });

  // Pause playing
  stage.pause();

  // Resume playing
  stage.resume();
});

Tree Model

Every app consists of a tree. The tree's root is provided as stage.

// Create a new node instance (with no textures)
var node = Stage.create();

// Append/prepend child to parent's children (accepts array)
parent.append(child);
parent.prepend(child);

// Append/prepend child to parent's children
child.appendTo(parent);
child.prependTo(parent);

// Insert sibling after/before child (accepts array)
child.insertNext(sibling);
child.insertPrev(sibling);

// Insert sibling after/before child
sibling.insertAfter(child);
sibling.insertBefore(child);

// Remove child from its parent
child.remove();

// Remove child from parent (accepts array)
parent.remove(child);

// Remove all of parent's children
parent.empty();

// Get parent's first/last (visible) child
parent.first(onlyVisible = false);
parent.last(onlyVisible = false);

// Get immediate parent
child.parent();

// Get child's next/prev (visible) sibling
child.next(onlyVisible = false);
child.prev(onlyVisible = false);

// Get node's visiblity
node.visible();
// Set node's visiblity
node.visible(visible);
node.hide();
node.show();

// Iterate over parent's children, child can not be removed
for (var child = parent.first(); child; child = child.next()) {
  // use child
}

// Iterate over parent's children, child can be removed
var child, next = parent.first();
while (child = next) {
  next = child.next();
  // use child
}

// Visit node's sub-tree including node itself
node.visit({
  start : function(node) {
    return skipChildren;
  },
  end : function(node) {
    return stopVisit;
  },
  reverse : reverseChildrenOrder = false,
  visible : onlyVisibleNodes = false
});

Game Loop

Each rendering cycle consists of ticking and redrawing the application tree. Application and its nodes can be updated during ticking. Depending on application activities there can be three different follow-ups after ticking:

  • If at least one node is touched then the entire application tree will be redrawn and the game loop will continue.
  • If no node is touched but at least one ticking function returns true then the game loop will continue but the previous drawing will be retained.
  • If no node is touched and no ticking function returns true then the application will pause until it is touched directly or indirectly.

Nodes can be touched directly by calling node.touch() but usually they are touched indirectly by other actions such as pinning or tree manipulation.

// Register a function to be called on ticking
node.tick(function(millisecElapsed) {
  return continueGameLoop;
}, beforeChildren = false);

// Touch node
node.touch();

Pinning

Pinning specifies how a node is attached to its parent. Pinning consists of size, transformation, positioning and transparency.

// Get a pinning value
node.pin(name);

// Set a pinning value
node.pin(name, value);

// Set one or more pinning values
node.pin({
  name : value,
  ...
});

When nameX equals nameY, name shorthand can be used instead.

Size

For some nodes, such as images, strings, rows and columns, size is set automatically.

node.pin({
  height : height,
  width : width
});

// Shortcut for setting size:
node.size(width, height);
node.width(width);
node.height(height);

// Shortcut for getting size:
node.width();
node.height();

Transformation

Transformation consists of scaling, skewing and rotating. Rotation is applied after scaling and skewing.

node.pin({
  scaleX : 1,
  scaleY : 1,
  skewX : 0,
  skewY : 0,
  rotation : 0
});

// Shortcut for setting transformation:
node.scale(x, y = x);
node.scale({ x : x, y : y });
node.skew(x, y = x);
node.skew({ x : x, y : y });
node.rotate(angle);

Positioning

When positioning, handle point on self is positioned at offset distance from align point on the parent. Handle and align are defined as a ratio of width/height, 0 is top/left and 1 is bottom/right. Handle defaults to the align value when it is not specified.

node.pin({
  alignX : 0,
  alignY : 0,
  handleX : 0,
  handleY : 0,
  offsetX : 0,
  offsetY : 0
});

// Shortcut methods for setting positioning:
node.offset(x, y);
node.offset({ x : x, y : y });

By default an axis-aligned bounding box (AABB) after transformation is used for positioning, however it is possible to use a non-transformed box by setting a pivot location. Pivot location is defined as ratio of non-transformed width/height and is used as central point on self for scale, skew and rotation.

node.pin({
  pivotX : 0,
  pivotY : 0
});

Transparency

Transparency can be applied to both node textures and subtree nodes or only node textures.

node.pin({
  alpha : 1,
  textureAlpha : 1
});

// Shortcut methods for setting transparency:
node.alpha(alpha);
node.alpha(alpha, textureAlpha);

Scale To

Scale to a new width/height, if mode is set to scale proportionally. Valid modes are:

  • in: maximum scale which keeps node edges inside the scaleWidth/Height
  • in-pad: like in, but evenly pads node to fill the entire scaleWidth/Height
  • out: minimum scale which keeps node edges outside scaleWidth/Height
  • out-crop: like out, but evenly crops it to scaleWidth/Height
node.pin({
  scaleMode : mode,
  scaleWidth : width,
  scaleHeight : height
});

// Shortcut method:
node.scaleTo(width, height, mode);

Events

Event listeners can be registered and unregistered to nodes, listeners are called when an event is published to a node. Some events may be published to multiple nodes, but events do not propagate.

// Register a listener to node
// Event `name` can be one or an array of strings or spaced separated strings
node.on(name, listener);

// Unregister a listener from node.
node.off(name, listener);

// Get listeners registered to node
// Returns an array or undefined
node.listeners(name);

// Call listeners with args
// Returns number of listeners called
node.publish(name, args);

Mouse and Touch

Native mouse and touch events are captured, processed and published to application nodes. Nodes receive mouse events in local coordinates, i.e. mouse location is specified as the distance to the top-left of the node.

// Add click listener to node
node.on('click', function(point) {
  // point.x and point.y are relative to this node left and top
  // point.raw is original event
});

Instead of native click events, syntatic click events are created and published to nodes. In addition to standard event types, a syntactic mousecancel event type is also supported which is similar to touchcancel but is published when a mousedown is not followed by mouseup.

// Mouse events:
Stage.Mouse.CLICK = 'click';
Stage.Mouse.START = 'touchstart mousedown';
Stage.Mouse.MOVE = 'touchmove mousemove';
Stage.Mouse.END = 'touchend mouseup';
Stage.Mouse.CANCEL = 'touchcancel mousecancel';

Texture

Textures are drawable objects which are used by tree nodes to draw graphics on the Canvas surface.

Texture Atlas

A texture atlas (sprite sheet) consists of a set of named textures which are referenced by name in an application.

Atlases are usually created using static image files. Images referenced in atlases are automatically preloaded.

// Adding texture atlas
Stage({
  name : 'mario', // optional
  image : {
    src : 'mario.png',
    ratio : 1, // optional, for high-res images
  }
  textures : {
    stand : { x : 0,   y : 0, width : 40, height : 60 },
    walk : [
      { x : 40,  y : 0, width : 40, height : 60 },
      { x : 80,  y : 0, width : 40, height : 60 },
      { x : 120, y : 0, width : 40, height : 60 }
    ],
    number : {
      '0' : { x : 0,  y : 60, width : 10, height : 14 },
      '1' : { x : 10, y : 60, width : 10, height : 14 },
      '2' : { x : 20, y : 60, width : 10, height : 14 },
      '3' : { x : 30, y : 60, width : 10, height : 14 },
      '4' : { x : 40, y : 60, width : 10, height : 14 },
      '5' : { x : 50, y : 60, width : 10, height : 14 },
      '6' : { x : 60, y : 60, width : 10, height : 14 },
      '7' : { x : 70, y : 60, width : 10, height : 14 },
      '8' : { x : 80, y : 60, width : 10, height : 14 },
      '9' : { x : 90, y : 60, width : 10, height : 14 }
    }
  }
});

Stage.image('mario:stand');

Stage.anim('mario:walk').play();

Stage.string('mario:number').value(100);

If image src starts with ./ it will be resolved relative to the current script URL.

Image

An image is a node with one texture.

// Create a new image instance
var image = Stage.image(texture);

// Change image texture
image.image(texture);

// Tile/Stretch image when pinning width and/or height
// To define borders add top, bottom, left and right to texture
image.tile();
image.stretch();

Animation

An animation or anim is a node with an array of textures as frames.

// Create a new anim instance
var anim = Stage.anim(textures, fps = 15);

// Get or set animation frame-per-second
anim.fps();
anim.fps(fps);

// Set animation frames, `textures` can be an array or a texture selector
anim.frames(textures);

// Go to n-th frame
anim.gotoFrame(n);

// Move n frames forward (or backward if n is negative)
anim.moveFrame(n);

// Get number of frames
anim.length();

// Start playing (from `frameName` if specified)
anim.play(frameName = undefined);

// Stop playing (and jump to `frameName` if specified)
anim.stop(frameName = undefined);

// Play `repeat * length` frames and then stop and call `callback`
anim.repeat(repeat, callback = null);

String

String is a row of images which are dynamically selected from frames using characters of a string value (or items of an array value).

// Create a new string instance with frames
var string = Stage.string(frames);

// Set frames, a string referencing a map in an atlas 
string.frames("digits");

// Set frames, a map with textures as values and frame names as keys 
string.frames({
  '0' : zeroTexture,
  '1' : oneTexture,
  ...
});

// Set frames, a function which takes a char (or item) and returns a texture
string.frames(function(char) {
  // create a texture for char
  return texture;
});

// Set value, it can be a string (or an array)
// Characters (or items) are used to select frames and create a row of images
string.value(value);

// Get assigned value
string.value();

Row and Column

A row/column is a node which organizes its children as a horizontal/vertical sequence.

// Create a new row/column
var row = Stage.row(childrenAlignY = 0);
var column = Stage.column(childrenAlignX = 0);

// Make node a row/column
node.row(childrenAlignY = 0);
node.column(childrenAlignX = 0);

// Add spacing between row/column cells
node.spacing(space);

Box (experimental)

A box resizes to wrap its children. It can be applied to tiled/stretched images to create variable size components such as windows and buttons.

// Create a new box
var box = Stage.box();

// Make node a box
node = node.box();

Tweening

Tweening is used to apply smooth transitions to pinning values.

// Create a tweening entry
// When `append` is true new entry is appended to current entries otherwise replaces them
var tween = node.tween(duration = 400, delay = 0, append = false);

// Set pinning values and start tweening
// Pinning shortcut methods, such as `.scale()`, can also be used
tween.pin(pinning);

// Set easing for tweening, it can be either a function or an identifier
// defined as 'name[-mode][(params)]', for example 'quad' or 'poly-in-out(3)'
// Names: linear, quad, cubic, quart, quint, poly(p), sin/sine, 
//        exp, circle/circ, bounce, elastic(a, p), back(s)
// Modes: in, out, in-out, out-in
tween.ease(easing);

// Set duration in milliseconds
tween.duration(ms);

// Set delay in milliseconds
tween.delay(ms);

// Callback when tweening is done
tween.done(function() {
  // this === node
});

// Remove this node when tweening ends
tween.remove();

// Hide this node when tweening ends
tween.hide();

// Create and chain a new tweening to this entry
var nextTween = tween.tween(duration = 400, delay = 0);

Global Methods

// Create a new app
Stage(function(stage, display) { });

// Create and preload a texture atlas
Stage({ });

// A function to be called before starting any app
// Can be used for preloading application assets
Stage.preload(function(done) {
  // Call `done` when loaded or failed
  done(error);
});

// Preload and execute a JS file
// URLs starting with `./` are resolved relative to current script URL
Stage.preload(src);

// Pause playing all applications
Stage.pause();

// Resume playing all applications
Stage.resume();

Development

To try examples with a live build run following command and check output for the URL to open in your browser:

npm run dev

License

Copyright 2020 Ali Shakiba http://shakiba.me/stage.js
Available under the MIT License

Comments
  • error: cannot find symbol import org.apache.cordova.CordovaWebViewClient;

    error: cannot find symbol import org.apache.cordova.CordovaWebViewClient;

    bonnie@bonnie ~/WorkStation/stage.js/example/game-orbit $ node -v v4.2.2 bonnie@bonnie ~/WorkStation/stage.js/example/game-orbit $ npm -v 2.14.7 bonnie@bonnie ~/WorkStation/stage.js/example/game-orbit $ cordova -v 5.4.0 bonnie@bonnie ~/WorkStation/stage.js/example/game-orbit $ cordova build Running command: /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/cordova/build ANDROID_HOME=/home/bonnie/Android/Sdk JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 Running: /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/gradlew cdvBuildDebug -b /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/build.gradle -Dorg.gradle.daemon=true :preBuild :compileDebugNdk UP-TO-DATE :preDebugBuild :checkDebugManifest :CordovaLib:compileLint :CordovaLib:copyDebugLint UP-TO-DATE :CordovaLib:mergeDebugProguardFiles UP-TO-DATE :CordovaLib:preBuild :CordovaLib:preDebugBuild :CordovaLib:checkDebugManifest :CordovaLib:prepareDebugDependencies :CordovaLib:compileDebugAidl UP-TO-DATE :CordovaLib:compileDebugRenderscript UP-TO-DATE :CordovaLib:generateDebugBuildConfig UP-TO-DATE :CordovaLib:generateDebugAssets UP-TO-DATE :CordovaLib:mergeDebugAssets UP-TO-DATE :CordovaLib:generateDebugResValues UP-TO-DATE :CordovaLib:generateDebugResources UP-TO-DATE :CordovaLib:packageDebugResources UP-TO-DATE :CordovaLib:processDebugManifest UP-TO-DATE :CordovaLib:processDebugResources UP-TO-DATE :CordovaLib:generateDebugSources UP-TO-DATE :CordovaLib:compileDebugJava UP-TO-DATE :CordovaLib:processDebugJavaRes UP-TO-DATE :CordovaLib:packageDebugJar UP-TO-DATE :CordovaLib:compileDebugNdk UP-TO-DATE :CordovaLib:packageDebugJniLibs UP-TO-DATE :CordovaLib:packageDebugLocalJar UP-TO-DATE :CordovaLib:packageDebugRenderscript UP-TO-DATE :CordovaLib:bundleDebug UP-TO-DATE :prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE :prepareDebugDependencies :compileDebugAidl UP-TO-DATE :compileDebugRenderscript UP-TO-DATE :generateDebugBuildConfig UP-TO-DATE :generateDebugAssets UP-TO-DATE :mergeDebugAssets UP-TO-DATE :generateDebugResValues UP-TO-DATE :generateDebugResources UP-TO-DATE :mergeDebugResources UP-TO-DATE :processDebugManifest UP-TO-DATE :processDebugResources UP-TO-DATE :generateDebugSources UP-TO-DATE :compileDebugJava /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:7: error: cannot find symbol import org.apache.cordova.CordovaWebViewClient; ^ symbol: class CordovaWebViewClient location: package org.apache.cordova /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:42: error: cannot find symbol webView.addView(fastView); ^ symbol: method addView(FastContextView) location: variable webView of type CordovaWebView /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:51: error: cannot find symbol ViewGroup webParent = (ViewGroup) webView.getParent(); ^ symbol: method getParent() location: variable webView of type CordovaWebView /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:58: error: no suitable method found for removeView(CordovaWebView) webParent.removeView(webView); ^ method ViewGroup.removeView(View) is not applicable (actual argument CordovaWebView cannot be converted to View by method invocation conversion) method ViewManager.removeView(View) is not applicable (actual argument CordovaWebView cannot be converted to View by method invocation conversion) /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:62: error: no suitable method found for addView(CordovaWebView) newLayout.addView(webView); ^ method ViewGroup.addView(View,int,LayoutParams) is not applicable (actual and formal argument lists differ in length) method ViewGroup.addView(View,LayoutParams) is not applicable (actual and formal argument lists differ in length) method ViewGroup.addView(View,int,int) is not applicable (actual and formal argument lists differ in length) method ViewGroup.addView(View,int) is not applicable (actual and formal argument lists differ in length) method ViewGroup.addView(View) is not applicable (actual argument CordovaWebView cannot be converted to View by method invocation conversion) /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:64: error: cannot find symbol webView.setBackgroundColor(Color.TRANSPARENT); ^ symbol: method setBackgroundColor(int) location: variable webView of type CordovaWebView /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:65: error: cannot find symbol webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); ^ symbol: method setLayerType(int,) location: variable webView of type CordovaWebView /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/src/com/piqnt/fastcontext/FastContextPlugin.java:66: error: cannot find symbol webView.setWebViewClient(new CordovaWebViewClient(cordova, ^ symbol: class CordovaWebViewClient 8 errors :compileDebugJava FAILED

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':compileDebugJava'.

      Compilation failed; see the compiler error output for details.

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 3.498 secs

    /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/cordova/node_modules/q/q.js:126 throw e; ^ Error code 1 for command: /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/build.gradle,-Dorg.gradle.daemon=true ERROR building one of the platforms: Error: /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/cordova/build: Command failed with exit code 1 You may not have the required environment or OS to build this project Error: /home/bonnie/WorkStation/stage.js/example/game-orbit/platforms/android/cordova/build: Command failed with exit code 1

    opened by souparno 9
  • publish to npm?

    publish to npm?

    Hey -- cool library!

    I'd love to be able to npm install this and require it node-style with a tool like browserify

    Are you up for doing an npm publish? With my PR you should be good to go.

    Npm recommends not using 'js' in the package name (I don't totally agree with this but whatever). However, there is an unrelated package cut on npm already -- maybe you could use "cut-engine" or "cut-renderer"?

    Or you could just publish it under "cutjs" and screw the convention.

    Note though that this only includes cut-web, I didn't really know what do with cut-fc and cut-cordova. If those need to be integrated I would still encourage publishing now so that people (like me) could start playing around with it in the npm/browserify way.

    opened by seanewest 8
  • How can I fill only a ship in asteroids game?

    How can I fill only a ship in asteroids game?

    Hello! Can you help me, please. I can't fill path shape ship for exemple color #e1181e, without others world. I tried: shipBody.shapes[0].proto = ui.p2; shipBody.shapes[0].proto.options.lineColor = '#e1181e'; But it paints all world to #e1181e. I need color ship to #e1181e and asteroids #808080. How i can do it? What am I doing wrong? Thank you. Best regards

    opened by edstarck 4
  • Coordinate of getImageData seems to be wrong

    Coordinate of getImageData seems to be wrong

    I'm using Stage.js to implement a magnifying glass effect like this.

    soap

    The circle in the top shows the magnified area around mouse position. I tried to read the pixels rendered by Stage.js using getImageData but got all 0 in data. My code is available here.

    I'm not sure if transformation of canvas in your game engine changed anything for getImageData, but I don't think this should be an issue since canvas spec states:

    The current path, transformation matrix, shadow attributes, global alpha, the clipping region, and global composition operator must not affect the getImageData() and putImageData() methods.

    Any idea how should I get the pixels around mouse position in this way? Or, what else game engine should I use to implement this magnifying glass effect?

    Thanks!

    opened by Ovilia 4
  • Long time no see.... I've update the Chinese Doc

    Long time no see.... I've update the Chinese Doc

    Because the changes between the old version and the new one are too disperse and too many, and I can't delete the old one. Well please change the Chinese Doc link in your English one to the new Chinese Doc. And I found a omission that at the end of Global Methods , the second section

    // Create and preload a texture atlas
    Stage({ });
    

    the parameter has nothing as its key or value. Is it right?

    Glad to interrupt you. Hahahahah Villor

    opened by vrbvillor 3
  • Should Tween._done be a list?

    Should Tween._done be a list?

    Thanks for the great project, @shakiba. Currently Tween._done supports one function. Should we make it a list, such that the following application will also work? img.tween(100).alpha(0).remove().done(fn)

    Otherwise, it will fail to remove since

    1. remove() set _done to this.remove(),
    2. but done(fn) will overwrite the _done. to fn.
    opened by tianzhuqiao 2
  • await is a reserved word (991:5)

    await is a reserved word (991:5)

    when i use gulp-babel to compile my project, thers is an error message blew, could u please fixd this issue?

    message: /Users/showzyl/Desktop/workspace/hybird/dsp/src/js/stage.js: await is a reserved word (991:5)

    opened by showzyl 2
  • scaleWidth not recognized in tween

    scaleWidth not recognized in tween

    I'm using scaleWidth instead of scale to make sure the texture is within 80% of the screen width and it works fine with the following setting.

    node.pin({
      alignX: -0.5,
      alignY: -0.5,
      scaleMode: 'in',
      scaleWidth: window.innerWidth * 0.8,
      scaleHeight: window.innerHeight * 0.2,
    });
    

    But it seems that scaleWidth is not recognized by tween and it just gets ignored. So what should I do if I want to set scaleWidth in tween?

    opened by Ovilia 2
  • Bump lodash from 4.17.15 to 4.17.19

    Bump lodash from 4.17.15 to 4.17.19

    Bumps lodash from 4.17.15 to 4.17.19.

    Release notes

    Sourced from lodash's releases.

    4.17.16

    Commits
    Maintainer changes

    This version was pushed to npm by mathias, a new releaser for lodash since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Is it possible to replace a node texture by a set of new animation frames?

    Is it possible to replace a node texture by a set of new animation frames?

    Let's say change animation from moveRight to MoveLeft on click?

    var node = Stage.anim(textures);
    
    onclick {
        node.frames(anothertextures);
        or
        node.play(anothertextures);
    }
    

    Thank you for this amazing library!

    opened by hesambayat 1
  • Adding image to testbed examples

    Adding image to testbed examples

    Hi, I am trying to add a background image to a testbed example. I have used the below code:

    ...
    // stage.empty();
        stage.background(testbed.background);
        stage.viewbox(testbed.width, testbed.height, 'in-pad');
        stage.pin('alignX', -0.5);
        stage.pin('alignY', -0.5);
    		stage.prepend(viewer);
    
    
    		
    Stage({
    	image : { src : '/media/assets/pinball.png', ratio : 1 },
      textures : {
        'board' : { x : 0, y : 0,  width : 320, height : 416 }
      }
    });
    ...
    

    But no image is rendered on the canvas?

    opened by burakk 0
  • Bump flat and mocha

    Bump flat and mocha

    Bumps flat to 5.0.2 and updates ancestor dependency mocha. These dependencies need to be updated together.

    Updates flat from 4.1.0 to 5.0.2

    Commits
    • e5ffd66 Release 5.0.2
    • fdb79d5 Update dependencies, refresh lockfile, format with standard.
    • e52185d Test against node 14 in CI.
    • 0189cb1 Avoid arrow function syntax.
    • f25d3a1 Release 5.0.1
    • 54cc7ad use standard formatting
    • 779816e drop dependencies
    • 2eea6d3 Bump lodash from 4.17.15 to 4.17.19
    • a61a554 Bump acorn from 7.1.0 to 7.4.0
    • 20ef0ef Fix prototype pollution on unflatten
    • Additional commits viewable in compare view
    Maintainer changes

    This version was pushed to npm by timoxley, a new releaser for flat since your current version.


    Updates mocha from 6.2.3 to 10.2.0

    Release notes

    Sourced from mocha's releases.

    v10.2.0

    10.2.0 / 2022-12-11

    :tada: Enhancements

    • #4945: API: add possibility to decorate ESM name before import (@​j0tunn)

    :bug: Fixes

    :book: Documentation

    v10.1.0

    10.1.0 / 2022-10-16

    :tada: Enhancements

    :nut_and_bolt: Other

    v10.0.0

    10.0.0 / 2022-05-01

    :boom: Breaking Changes

    :nut_and_bolt: Other

    ... (truncated)

    Changelog

    Sourced from mocha's changelog.

    10.2.0 / 2022-12-11

    :tada: Enhancements

    • #4945: API: add possibility to decorate ESM name before import (@​j0tunn)

    :bug: Fixes

    :book: Documentation

    10.1.0 / 2022-10-16

    :tada: Enhancements

    :nut_and_bolt: Other

    10.0.0 / 2022-05-01

    :boom: Breaking Changes

    :nut_and_bolt: Other

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump express from 4.17.1 to 4.17.3

    Bump express from 4.17.1 to 4.17.3

    Bumps express from 4.17.1 to 4.17.3.

    Release notes

    Sourced from express's releases.

    4.17.3

    4.17.2

    Changelog

    Sourced from express's changelog.

    4.17.3 / 2022-02-16

    4.17.2 / 2021-12-16

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump qs from 6.7.0 to 6.11.0

    Bump qs from 6.7.0 to 6.11.0

    Bumps qs from 6.7.0 to 6.11.0.

    Changelog

    Sourced from qs's changelog.

    6.11.0

    • [New] [Fix] stringify: revert 0e903c0; add commaRoundTrip option (#442)
    • [readme] fix version badge

    6.10.5

    • [Fix] stringify: with arrayFormat: comma, properly include an explicit [] on a single-item array (#434)

    6.10.4

    • [Fix] stringify: with arrayFormat: comma, include an explicit [] on a single-item array (#441)
    • [meta] use npmignore to autogenerate an npmignore file
    • [Dev Deps] update eslint, @ljharb/eslint-config, aud, has-symbol, object-inspect, tape

    6.10.3

    • [Fix] parse: ignore __proto__ keys (#428)
    • [Robustness] stringify: avoid relying on a global undefined (#427)
    • [actions] reuse common workflows
    • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, tape

    6.10.2

    • [Fix] stringify: actually fix cyclic references (#426)
    • [Fix] stringify: avoid encoding arrayformat comma when encodeValuesOnly = true (#424)
    • [readme] remove travis badge; add github actions/codecov badges; update URLs
    • [Docs] add note and links for coercing primitive values (#408)
    • [actions] update codecov uploader
    • [actions] update workflows
    • [Tests] clean up stringify tests slightly
    • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, safe-publish-latest, tape

    6.10.1

    • [Fix] stringify: avoid exception on repeated object values (#402)

    6.10.0

    • [New] stringify: throw on cycles, instead of an infinite loop (#395, #394, #393)
    • [New] parse: add allowSparse option for collapsing arrays with missing indices (#312)
    • [meta] fix README.md (#399)
    • [meta] only run npm run dist in publish, not install
    • [Dev Deps] update eslint, @ljharb/eslint-config, aud, has-symbols, tape
    • [Tests] fix tests on node v0.6
    • [Tests] use ljharb/actions/node/install instead of ljharb/actions/node/run
    • [Tests] Revert "[meta] ignore eclint transitive audit warning"

    6.9.7

    • [Fix] parse: ignore __proto__ keys (#428)
    • [Fix] stringify: avoid encoding arrayformat comma when encodeValuesOnly = true (#424)
    • [Robustness] stringify: avoid relying on a global undefined (#427)
    • [readme] remove travis badge; add github actions/codecov badges; update URLs
    • [Docs] add note and links for coercing primitive values (#408)
    • [Tests] clean up stringify tests slightly
    • [meta] fix README.md (#399)
    • Revert "[meta] ignore eclint transitive audit warning"

    ... (truncated)

    Commits
    • 56763c1 v6.11.0
    • ddd3e29 [readme] fix version badge
    • c313472 [New] [Fix] stringify: revert 0e903c0; add commaRoundTrip option
    • 95bc018 v6.10.5
    • 0e903c0 [Fix] stringify: with arrayFormat: comma, properly include an explicit `[...
    • ba9703c v6.10.4
    • 4e44019 [Fix] stringify: with arrayFormat: comma, include an explicit [] on a s...
    • 113b990 [Dev Deps] update object-inspect
    • c77f38f [Dev Deps] update eslint, @ljharb/eslint-config, aud, has-symbol, tape
    • 2cf45b2 [meta] use npmignore to autogenerate an npmignore file
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump loader-utils from 1.4.0 to 1.4.2

    Bump loader-utils from 1.4.0 to 1.4.2

    Bumps loader-utils from 1.4.0 to 1.4.2.

    Release notes

    Sourced from loader-utils's releases.

    v1.4.2

    1.4.2 (2022-11-11)

    Bug Fixes

    v1.4.1

    1.4.1 (2022-11-07)

    Bug Fixes

    Changelog

    Sourced from loader-utils's changelog.

    1.4.2 (2022-11-11)

    Bug Fixes

    1.4.1 (2022-11-07)

    Bug Fixes

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • remove stage

    remove stage

    HI, How can I delete a stage completely? I want to switch between multiple games so I need to be able to delete the previous game from memory and run the new game.

    opened by meghe2000 0
Releases(v0.8.8)
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.

Phaser - HTML5 Game Framework Phaser is a fast, free, and fun open source HTML5 game framework that offers WebGL and Canvas rendering across desktop a

Richard Davey 33.4k Jan 7, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
HTML5 Game Engine

Quintus Engine Quintus is an easy-to-learn, fun-to-use HTML5 game engine for mobile, desktop and beyond! The Quintus engine is an HTML5 game engine de

Pascal Rettig 1.4k Dec 21, 2022
Embeddable 3D Rendering Engine with JS, a POC project.

Three.V8 Three.V8 is a proof of concept (POC) of an embedabble 3D rendering engine using JavaScript as user script. Currently, the whole project requi

Fei Yang 24 Nov 29, 2022
Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data templates in pure HTML.

Tempo 2.0 Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data templates in pure HTML. Why use Tempo? Clear separati

Twigkit 707 Jan 3, 2023
A W3C standard compliant Web rendering engine based on Flutter.

WebF WebF (Web on the Flutter) is a W3C standard compliant Web rendering engine based on Flutter, it can run web application on Flutter natively. W3C

openwebf 418 Dec 25, 2022
A simple library to draw option menu or other popup inputs and layout on Node.js console.

console-gui-tools A simple library to draw option menu or other popup inputs and layout on Node.js console. console-gui-tools A simple Node.js library

Elia Lazzari 12 Dec 24, 2022
Lightweight and independent Pinterest-like cascading grid layout library

Bricklayer is a Lightweight and Independent Pinterest-like Cascading Grid Layout Library ?? Simpler than any other cascading grid layout tools. ❄️ Lig

Adem ilter 2.5k Dec 22, 2022
Create a card layout that let your user flip through it like you see on Google Tips

#Tip Cards by Pete R. Create an animated card layout that let your viewer flip through it like you see on Google Tips Page. Created by Pete R., Founde

Pete R. 213 Nov 5, 2022
Script para crear un layout tipo masonry.

light-masonry Script para crear un layout tipo masonry. Solo es necesario tener el contenedor junto a sus hijos que se acomodaran en este tipo de layo

Lenin Felix 2 Feb 4, 2022
Use jsx to make scriptable's layout.

scriptable-jsx This project helps you to write Scriptable widgets with JSX syntax. And add some useful tools by the way. you can check demos in demo f

毛球 8 Oct 10, 2022
Chrome & Firefox extension to return old Twitter layout from 2015.

OldTwitter (2022) Chrome extension to return old Twitter layout from 2015. This extension doesn't add any CSS on top of original Twitter. It's fully o

dimden 35 Jan 4, 2023
Minimalist dependancy free Masonry layout library

MiniMasonry.js Minimalist dependency free Masonry layout library MiniMasonry is a lightweight dependency free Masonry layout. It will compute elements

Spope 343 Dec 4, 2022
Print seat layout for movie, flight (jQuery plugin)

seatLayout.js (movie-seat-layout) Print seat layout for movie, flight and seat selection (jQuery plugin) Demo : https://sachinkurkute.github.io/movie-

Sachin Kurkute 20 Dec 8, 2022
Examples for Wonderland Engine -- development platform for VR, AR and 3D on the web.

Wonderland Engine Examples Repository of official examples for Wonderland Engine, development platform for VR, AR and 3D on the web. License The code

Wonderland Engine 7 Nov 5, 2022
HTML5 game framework for web and iOS

#LimeJS ##Getting started: ###Mac OS X and Linux users: Requirements: Python 2.6+, Git Clone the git repo (you have probably already done that): git c

Digital Fruit 1.4k Dec 1, 2022
Recreated Chromium T-Rex game in Phaser 3, written in HTML5 & TypeScript

Chromium Dino Game - Phaser 3 + TypeScript + Parcel Chromium Dino Game Clone using Phaser 3 + TypeScript + Parcel Play You can play online here Dino P

Mai Hoàng Anh Vũ 3 Jun 21, 2022