Jump to content

Simple switching screen with Phaser


dluz
 Share

Recommended Posts

Hello everyone, I am newbie with PhaserJs. I have previous experience with enchantJs. In this engine, to change the screen (for example: "gameloop" or "mainmenu") is easy, using the concept of scene.I wonder if there is a way to do it so well simplified

in PhaserJs.

 

Sorry for my English.

Link to comment
Share on other sites

Phaser has a State class. You can implement different State objects for your menu, level select, game etc. Each state has a create and update method which you can implement. Put initialisation code in "create" and put your game logic or menu logic code in the "update" method because that method will be called for each frame.
 
Then, to switch between states you can do something like this:
this.state.start('MainMenu'); // state name is case sensitive btw

As far as I know there is no transition animations but you can add tween or something like that yourself. For more info see this excellent Getting Started With Phaser post by end3r.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...