From 00c7a6c31a159b2dbbd9ffcdb74bcc4fa8d045ac Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Thu, 2 May 2019 22:02:55 -0700 Subject: [PATCH] Fixed issue where engine entities weren't cleared after exiting GameScreen --- core/src/com/riiablo/entity/Engine.java | 6 ++++++ core/src/com/riiablo/screen/GameScreen.java | 1 + 2 files changed, 7 insertions(+) diff --git a/core/src/com/riiablo/entity/Engine.java b/core/src/com/riiablo/entity/Engine.java index a4de939d..61d9d879 100644 --- a/core/src/com/riiablo/entity/Engine.java +++ b/core/src/com/riiablo/entity/Engine.java @@ -12,6 +12,12 @@ public class Engine implements Iterable { public Engine() {} + public void clear() { + entitiesById.clear(); + entities.clear(); + nextEntityId = 33; + } + public Entity getEntity(int id) { return entitiesById.get(id); } diff --git a/core/src/com/riiablo/screen/GameScreen.java b/core/src/com/riiablo/screen/GameScreen.java index 001cfa0e..a68613f5 100644 --- a/core/src/com/riiablo/screen/GameScreen.java +++ b/core/src/com/riiablo/screen/GameScreen.java @@ -749,6 +749,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable @Override public void dispose() { + Riiablo.engine.clear(); stage.dispose(); escapePanel.dispose(); controlPanel.dispose();