Jump to content

Reference initial state


Habacucc
 Share

Recommended Posts

Hello :). I created my game like this:
 

 

var game= new Phaser.Game(800,600, Phaser.AUTO, '', {preload:preload, create:create, update:update});

 

If I'm not wrong, I created an initial state ( {preload:preload, create:create, update:update} ) which is called automatically at the beginning of the game.

 

How can I reference this initial state from other states I created? Like, if I start my game with:

 

 

game.state.start('MainMenu');

 

How can I call the initial state from the MainMenu state?

Link to comment
Share on other sites

Because you've set the initial state as an object literal I don't think you can retrieve it. If you look at this basic example project (specifically the index.html file), you'll see that the states are all set up with game.state.add, and the 'Boot' state becomes the initial state. Doing it this way ensures all of them have a name you can reference.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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