Have the Screen call remove() on all Entities before removing them.

This commit is contained in:
Jan Philipp Timme 2014-11-04 20:23:21 +01:00
parent a91a60381c
commit 95f3e05fed
1 changed files with 4 additions and 0 deletions

View File

@ -95,6 +95,10 @@ public abstract class Screen {
*/ */
public void cleanup() { public void cleanup() {
if(this.overlay != null) this.overlay.cleanup(); if(this.overlay != null) this.overlay.cleanup();
//tell all entities to cleanup themselves.
for(Entity e : this.getEntities()) {
e.remove();
}
this.entities.removeAll(this.entities); this.entities.removeAll(this.entities);
} }