caiser Posted December 5, 2015 Share Posted December 5, 2015 Hello guys, I am building a puzzle game which has more than 100 levels.For each puzzle/level, I am planning to create a state, so for example I will be having: level1.js, level2.js, ... level100.js Is this a good practice or it might raise few issues ? Thanks Link to comment Share on other sites More sharing options...
rich Posted December 5, 2015 Share Posted December 5, 2015 It's not how I'd do it personally (I'd have a more generic Level State that loads in what it needs each time), but having said that I still can't see a problem with having 100 states. As long as you clean up on the state shutdown, so nothing lingers in memory when it shouldn't do, it should be fine. States are generally really light-weight. You could eat up more memory in a single sprite texture than in 100 states. It's just the gc to be careful of. Link to comment Share on other sites More sharing options...
caiser Posted December 6, 2015 Author Share Posted December 6, 2015 Thanks a lot rich. Just to be clear, does phaser clean up everything when I move to one state or another or I have to do few things manually ?And by "gc", you mean Game Content ? Link to comment Share on other sites More sharing options...
CtlAltDel Posted December 6, 2015 Share Posted December 6, 2015 garbage collect(or)(ion) Link to comment Share on other sites More sharing options...
caiser Posted December 6, 2015 Author Share Posted December 6, 2015 Thanks Link to comment Share on other sites More sharing options...
rich Posted December 6, 2015 Share Posted December 6, 2015 It will clear some things, the display list for example, but it won't destroy anything or remove any custom objects - so you need to be sure you're doing that in the shutdown. caiser 1 Link to comment Share on other sites More sharing options...
caiser Posted December 9, 2015 Author Share Posted December 9, 2015 Thanks rich, But I think I'll have to find another way (maybe use a generic state as you said)Loading 100+ js file in the index.html is not a good idea... Link to comment Share on other sites More sharing options...
Recommended Posts