Chendler Posted August 20, 2014 Share Posted August 20, 2014 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 2etc. 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 More sharing options...
ZoomBox Posted August 20, 2014 Share Posted August 20, 2014 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. Chendler 1 Link to comment Share on other sites More sharing options...
eguneys Posted August 20, 2014 Share Posted August 20, 2014 I've written an article showing an example level system using states. http://www.sitepoint.com/javascript-game-programming-using-phaser/ Chendler 1 Link to comment Share on other sites More sharing options...
Chendler Posted August 21, 2014 Author Share Posted August 21, 2014 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 More sharing options...
Chendler Posted August 26, 2014 Author Share Posted August 26, 2014 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 More sharing options...
Recommended Posts