mokargas Posted July 21, 2016 Share Posted July 21, 2016 Hey all, I'm creating a basic platformer that loads levels from JSON files, output from the Tiled map maker http://www.mapeditor.org/. Currently I simply preload the first level JSON, and render it to screen. This works really great. However, I have created 25 levels now (with a view to adding more), each with their own JSON files, so I'm considering more extensible and performant approaches to loading levels. Reading the forums, it has been mentioned that creating a static state for each of these levels is too intensive, and I think preloading 50 JSON files to upfront is probably a bit intensive as well. I'm wondering how other Phaser devs handle this problem? Link to comment Share on other sites More sharing options...
SolitudeX Posted July 22, 2016 Share Posted July 22, 2016 Add a param to the level state's init function ,load different level according to the param. Game.Main.prototype = { init: function (lv) { level =lv; }, create:function(){ loadLevel(level); } //Codes... And start the state: game.state.start("Main", true, //clear world true, //clear cache (loaded assets) 1 //param(s) ); Link to comment Share on other sites More sharing options...
Recommended Posts