State Transition Plugin for Phaser
Currently the switch between states is really static and a game should be able to transition between states. Therefore, this plugin does exactly that: draws the
game.world into a
renderTexture which is rendered on a
sprite, and finally it's tweening that sprite.
How to use it
You have several options here
Just download the
dist/phaser-state-transition.min.js file and you're done
npm install phaser-state-transition --save, and you could reference it later.
Since we're talking about v2, there's been some changes. Now, the plugin basically overrides the create state method, so you could keep you're code the same, and just add transition configs where you see fit.
game.state.start('playState', [outTransition, [inTransition]], clearWorld, clearCache, parameters);
Notice the 2 optional params, that are transition config instances. There are several available by default, you should run this:
console.log(Phaser.Plugin.StateTransition.In);. Obviously you could easily add your own nice transition as well.
If there's something you think it could be improved let me know, or create a pr.