Jump to content

Switching states with presitance?


oliversb
 Share

Recommended Posts

You could maybe try *without* switching states.

 

Clear only your unwanted data (like the level, groups etc.) and re create/ re position old sprites within the same state.

Or you could pass through data when creating a new state like:

goEndScreen() {            this.game.state.states['EndGame'].count_deaths = this.count_deaths; //make the data match            this.game.state.start('EndGame', true, false); //then load the state        }//I guess you might be able to pass through sprites like this too?!

I think a built-in persistent state data is a feature still in development. (Sub-States) 

 

The complicated way would be to save your persistent data within a database on your web server ... I'd love to know how to do that...

Link to comment
Share on other sites

Actually you can't, as phaser is made today.

 

It's on the roadmap however, to include persisting states.

 

A solution could be an object where you store players data such as life, weapon type, score, previous state name, etc... That you update each time a state is left.

Link to comment
Share on other sites

Afair the state change clears the world. You might get around adding directly to stage (or creating own persisting world group which is in stage).  However the stage change clears also timers which maybe problem. I made workaround for timer clearing making my objects to resume timers when state changes.

 

Also make note that there are points to take care to destroy() your objects manually to let GC take over.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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