Jump to content

Simple switching screen with Phaser


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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