Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Best way to create multiple levels


BrokenSkyDev
 Share

Recommended Posts

I have had some success with this approach: 

 

I create a JSON file that holds level definitions - number and type of sprite-based objects, placement and basic behaviors for each kind of game object that can change in a level.  The format is a big array of objects, with each object representing a level and itself having multiple arrays specifying the kind of stuff I already mentioned.

 

In Game create I lay down stuff that doesn't change.  Upon each level change I show level change animation and then I load up the new level based upon the level definition for that level.

 

I try to create object pools for stuff that gets re-used a lot instead of creating and destroying stuff for each level, to avoid gc jitter, but I end up doing some destroying and recreating some stuff for sure.  I know under the hood that Pixi does a lot of texture caching, but most of the objects I am caching tend to be "class-based" built upon a basic sprite, but having additional behaviors and properties.

 

Once you have put in the work to do this, you can create new levels with a text editor.  Granted, certain kinds of games lend themselves more to this approach than others.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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