Jump to content

Levels management with states


Chendler
 Share

Recommended Posts

Hello, developers.

Today I asked th question about infinity background realization.

 

Now I have the next questions.

 

1) level management

 

I try to create game with 3 levels. What the best levelt to create levels system?

I have the next plan:

 

- start play state with first level, then after player won

- get current level from my js object

- start play state with level 2

etc.

 

But does exist the best way?

 

2) states

 

Now I have play state and menu state (menu has resume, sound level etc.)

How to change state to 'menu' and then return to 'play' state without broke game?

 

Now my resume button just reload the game.

Thank you.

Link to comment
Share on other sites

1) I think the best way is to launch the same play-state with different variables stored in a javascript object. So you launch the same play-state but with different parameters to have a different level.

2) States are not managed to act this way I believe. If you wish an ingame menu (with the game "paused" in the background) then you should keep it in the play-state.

Link to comment
Share on other sites

1) I think the best way is to launch the same play-state with different variables stored in a javascript object. So you launch the same play-state but with different parameters to have a different level.

2) States are not managed to act this way I believe. If you wish an ingame menu (with the game "paused" in the background) then you should keep it in the play-state.

 

I think too.

Thanks for your opinion.

Link to comment
Share on other sites

I found good solution.

When you start level with state logic you can do it such as:

game.state.start('play', true, false, customParameter);

See the doc here - http://docs.phaser.io/Phaser.StateManager.html#start

 

You should catch this customParameter in init function of your state:

playState = {    init: function(customParameter) {        console.log(JSON.stringify(customParameter));    }}

I use this method for level system.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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