Nambiar Posted January 26, 2014 Share Posted January 26, 2014 I've prepared a small tutorial for managing game states using Phaser. Its fairly straightforward to figure out yourself, but I'll just put it out there nonetheless. [Edit :- The earlier link was broken. You can find a copy (from memory) of the tutorial here - http://gamedolph.in/tutorials/state-management-tiny-tutorial/ ] salcapolupo, Nebulocity, totallybueno and 4 others 7 Link to comment Share on other sites More sharing options...
jerome Posted January 26, 2014 Share Posted January 26, 2014 very interesting tutorial ! Link to comment Share on other sites More sharing options...
Nebulocity Posted January 26, 2014 Share Posted January 26, 2014 I look forward to reading this after I get some much-needed sleep ;-) Link to comment Share on other sites More sharing options...
Biggerplay Posted January 26, 2014 Share Posted January 26, 2014 I've prepared a small tutorial for managing game states using Phaser. Its fairly straightforward to figure out yourself, but I'll just put it out there nonetheless. http://s-nambiar.com/tutorials/managing-game-states-phaser/ Thanks for the tutorial. Something I'm still not clear on is what happens to the states vars etc when the game switches to another state? does the state manager delete things and clear everything up? or it doesn't and that's up to the developer to take of? Link to comment Share on other sites More sharing options...
Nambiar Posted January 26, 2014 Author Share Posted January 26, 2014 Thanks for the tutorial. Something I'm still not clear on is what happens to the states vars etc when the game switches to another state? does the state manager delete things and clear everything up? or it doesn't and that's up to the developer to take of? State-manager -> start() The docs say that it does by default. Though there are other options too, like the destroy() and remove() too. Check them out Edit :-I ran a memory profile on one of my games, and this is what happened ... So I guess it does what it claims Link to comment Share on other sites More sharing options...
Biggerplay Posted January 26, 2014 Share Posted January 26, 2014 State-manager -> start() The docs say that it does by default. Though there are other options too, like the destroy() and remove() too. Check them out Edit :-I ran a memory profile on one of my games, and this is what happened ... So I guess it does what it claims I know it depends on how you have coded your game, but doesn't that graph show a slight increase in memory usage even after each state change? Link to comment Share on other sites More sharing options...
Nambiar Posted January 26, 2014 Author Share Posted January 26, 2014 I know it depends on how you have coded your game, but doesn't that graph show a slight increase in memory usage even after each state change?The fact that memory use drops at the exact same moment that I change state (different from the usual see-saw pattern during a state) seems to say that a major mem change happened. Now, to pin point if it does what is expected, i'll have to open up the js file ... sooooo lazy... Link to comment Share on other sites More sharing options...
totallybueno Posted January 27, 2014 Share Posted January 27, 2014 Thanks for the tutorial Nambiar, I was waiting for this Link to comment Share on other sites More sharing options...
csimpson.web Posted June 19, 2014 Share Posted June 19, 2014 hi , the tutorial isnt there anymore Link to comment Share on other sites More sharing options...
rjungemann Posted June 19, 2014 Share Posted June 19, 2014 If you set objects/arrays as instance variables on your state, you'll want to set them back to null on shutdown, otherwise they won't get garbage collected. Which can cause memory usage to grow over time. Be careful with closures for the same reason. Link to comment Share on other sites More sharing options...
Edricus Posted June 20, 2014 Share Posted June 20, 2014 I've prepared a small tutorial for managing game states using Phaser. Its fairly straightforward to figure out yourself, but I'll just put it out there nonetheless. http://s-nambiar.com/tutorials/managing-game-states-phaser/ You're tutorial seems to not be there anymore. I tried clicking on the link and it just takes me a your WordPress page but not tutorial. Link to comment Share on other sites More sharing options...
Nambiar Posted June 20, 2014 Author Share Posted June 20, 2014 Yes I am sorry about this state of affairs. Lax security on the original site meant someone got hold of admin powers and decided to ruin everything. Link to comment Share on other sites More sharing options...
Nambiar Posted June 20, 2014 Author Share Posted June 20, 2014 I've made a copy of the same tutorial on the new site. You can find it here - http://gamedolph.in/tutorials/state-management-tiny-tutorial/ Link to comment Share on other sites More sharing options...
Dread Knight Posted December 24, 2014 Share Posted December 24, 2014 Thanks for the tutorial, will check it out as I need to learn more about this stuff. I know it depends on how you have coded your game, but doesn't that graph show a slight increase in memory usage even after each state change? Well, they're pretty close, but the other states might have more stuff in them, requiring more memory Link to comment Share on other sites More sharing options...
strifecrafter Posted March 1, 2015 Share Posted March 1, 2015 Hi,I just finished reading through the tutorial and I have some newbie questions. First -in the tutorial you mention that a typical Phaser game is made up of these states: "Now for the actual explanation. Matching Pairs is set up into 5 states -> Boot, Preloader, MainMenu, EndScreen and Game. " In the latest version of the basic index.html on the Phaser repo, it only adds 4 game states - and leaves out EndScreen https://github.com/photonstorm/phaser/blob/master/resources/Project%20Templates/Basic/index.html So, I am assume that you don't need to add all of the game states, if you don't want to - that Phaser only actually uses the states you explicitly add/declare? I understand how this passes control to the "Boot" function / state:game.state.start('Boot'); //starting the boot state What I do not understand is - in Boot.js there are multiple methods declared: In the tutorial: preload, createIn the repot version of Boot.js https://github.com/photonstorm/phaser/blob/master/resources/Project%20Templates/Basic/Boot.jsthese methods are declared: init, preload, create Sooo.... Is "init" optional since the tutorial does not declare it?What determines the order in which these methods are called? I assume they are being called automatically by the Phaser engine, once control passes to Boot? I did search for "boot" through phaser.js - and didn't really find the answer to these questions - but I'm sure they are in the someplace, and I just don't recognize them...https://raw.githubusercontent.com/photonstorm/phaser/master/build/phaser.js I appreciate any enlightenment.... thanks Link to comment Share on other sites More sharing options...
Recommended Posts