- Home /
How to manage multiple levels in the 2D game ?
I am working on simple 2d game which will publish for mobile devices.
Many games such as Angry birds, Candy crush, etc. Suppose there are 100 or more than levels in the game, how do I manage all levels in my game ? Such as object positions ? B'coz in each level, there is a different pattern of objects (obstacles) !
I have to optimize as much as I can.
Which technique should I implement ?
Make every level in the separate scene & load the specific scene whenever needs.
Keep all levels in one scene but save all object's positions to text file in each level, So when user choose level-X then design pattern (vector3 position - arrays) of level-X can be known through text file (fetching positions from text file and set it to vector3 array of object). then set those positions to objects of specific level.
I think, making each level in separate scene, is a worst case.
What is most efficient solution ?
Answer by RJproz · Jul 25, 2015 at 06:28 AM
The second option!! 2D games doesn't require Shadows or lightmaps. So you can just save the Transforms of each object in Json or XML file. This also facilitates in adding levels online, just by using simple web service, where you can update 20-30 levels each week without updating the actual app.
Answer by Cynikal · Jul 25, 2015 at 06:49 AM
As RJProz stated, the 2nd option is the most efficient.
You could have your app download level files from a webserver as well. This would provide a fully dynamic level system.
I am also making a 2d game with levels. But I am already using a first system. How much its slowing down the game?
I think, it's not good practice to making levels in separate scene for simple 2d game. If possible then manage everything in single scene. Do eneble or disable gameobject containers when it's needs.
Answer by Nikunj-Kareliya · Jul 26, 2015 at 02:33 PM
I am complete beginner to use a webservice or xml parser. I didnt use yet.
I did search. then I found this link : appcrafted , Is there any easy solution ?
Let me explain again problem in detail:
Suppose there are 200 levels, in the 1st level I have 50 tiles, and all tiles are placed in certain pattern, same as in 2nd level I have 100 tiles which are arranged in different pattern than 1st case, So each level has it's unique pattern of tiles.
Please, note: size & property of tiles are different in the different levels. Every type of tile has a unique feature.
Should I do like, arrange a pattern of tiles of level-X in editor then place all tiles of level-X under a parent game object, then make that parent object to prefab. So, load a appropriate prefab when it needs. It seems like easy to do.
Technically, prefabs just stores references and metadata. If you are sure that you don't want to add levels via Web service, then you can go with your idea. Create prefab of each level. Just make sure that you keep all levels in Resources folder, and load them using Resources.Load and unload then when not needed.