I am currently working on an entity system based game using artemis and libgdx and I am wondering how I should handle level changing in such a configuration.
For example, with a Mario-like platformer:
First Mario starts the level, the engine instantiates a new World() loading the tilemap and initializing all the objects.
What if Mario goes through a pipe? The world inside the pipe is a new World()? or does the camera only focus on another part of a world?
If we have a new world, artemis doesn't allow detaching an entity from a world, so may I clone the player entity and add it to the new world?
Does someone know how to handle this kind of level part changing (Mario's part / Abe's odyssey screens)? What are the common ways to achieve this using an artemis-like framework?
I finally decided to add a room object layer defining rectangles (see picture below)
Each room is a rectangle with it's x, y coordinate and width, height dimensions. Each room defined the bounds where the camera is allowed to move, if the player intersect with another room, the camera slide from room n to room n+1 along the x axis or the y axis, if the room is bigger than the screen, the camera is allowed to scroll.
I have been able to improve performance and to solve a lot of issues using this approach, it is possible to only process the entities contained within the current room instead of calculating the full world at each frame.