Changing levels in-game

Hello, What would be the best way to change levels once the player has completed a certain action? In my game the player has to kill a final boss to get to the next one, so inside the simpleUpdate method I do the required comparisons and then detach the level 1 node and attach the level 2 node to the rootNode but this doesn’t change the scene itself and instead it starts to lag

If you detach the node and it doesn’t really detach… then you didn’t really detach it.

You probably want to handle the different levels in AppStates because you will most likely have different kinds of enemies in the levels and you may want to change the available weapons or something. I wouldn’t just detach the terrain and attach the new one.

also, if you just detach the level from the scenegraph you’ll still have item in the physics space and it will result in weird comportements.

Changing a level is not that easy. A program is like an aicraft, you have to start, fly and the land. Most programmers just do the start and fly part, then add a button “explose in the air” and let the OS clean everything. This can work for small apps (or command line apps that perform a single job). But a “game with different levels” includes a landing somewhere, so it’s not an easy thing.

Also, you can notice that programs like “league of legends” have a separate program for the game itself and for the lobby. They didn’t want to bother with a landing, so they use 2 different programs. But the result is pretty ugly, isn’t it ?