Easily chain your Phaser game code.

Article by Richard Davey. Posted on 15th Jun 2016.   @phaser_

image

Webcaetano has created a plugin for Phaser that allows you to make it more chainable.

Here is how you'd normally create a Sprite in Phaser:

var sprite = game.add.sprite(0,0,'phaser-dude');
sprite.x = 100;
sprite.y = 100;
sprite.anchor.setTo(0.5,0.5);
sprite.tint = 0xFF0000;

And the Craft approach:

var sprite = craft.$sprite('phaser-dude')
.$set({
  x:100,
  y:100
})
.$mid()
.$tint('#FF0000');

// phaser vanilla still works
sprite.x = 200;

The plugin is exported in UMD so it works in global variables, ES6, webpack, and browserify.

Read More