TGB/Tutorials/Changing Levels

From TDN

Changing Levels

The first thing you need is a Project. Go ahead and make one and name it LevelTest.

Next create a new level and name it Level1. Put some random image into it so we can tell when it is loaded. Next create another level and you guessed it Level2. Put a different random level into that.

Run Level1 and type this code into the console. Access it by the ~ key (It is next to the number 1).


sceneWindow2D.schedule(20,"loadLevel", "game/data/levels/Level2.t2d");


The reason I didn't use sceneWindow2D.loadLevel("game/data/levels/Level2.t2d"); is because sometimes it makes the engine unstable resulting in a crash. If you want a more detailed explanation you can find it here. Garage Games Forum.