For my game, Im using
- Ashley (ECS)
Ive got a lot of screens but for simplification:
In InGameScreen Im init the ECS (Ashley) and create a lot of entities. Some have PhysicsComponent. The PhysicsSystem will catch them and call Box2D to spawn some objects based on the parameters within the PhysicsComponents.
So far so good.
Now, when the player dyes, I run
setScreen(new MainMenuScreen()); from my "Main"-Class (MyGame.java).
- the game starts and
MyGameloading at first the
- than the
InGameScreenwill get loaded (when player presses a key)
- than the player dyes
MyGamerecognized it and loading again (throu calling
- When Player press key:
MyGameloading another round (
I guess I have to do something like a complete clean up between switching screens. But how should I implement this? Just "deleting" the old InGameScreen-Object shouldent be enought, right?
- Do I have to use the
- Is it enough to instantiate everything new (in the
InGameScreen) since it will instantiate all child-object new for its own like
Box2DWorld world = new World();