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.
You have several options here
Just download the dist/phaser-state-transition.min.js
file and you're done
Run 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]]);
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.Out);
and 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.