Jump to content

Level Loading approaches?


Recommended Posts

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

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;


And start the state:

    true, //clear world   
    true, //clear cache (loaded assets) 
    1 //param(s)


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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