Skip to content

Instantly share code, notes, and snippets.

@tdgroot
Last active April 4, 2016 19:31
Show Gist options
  • Save tdgroot/a05d669208a05f98e8074761af5aad98 to your computer and use it in GitHub Desktop.
Save tdgroot/a05d669208a05f98e8074761af5aad98 to your computer and use it in GitHub Desktop.
public class DisposableEngine extends Engine {
public void dispose() {
ImmutableArray<Entity> entities = getEntities();
for (Entity e : entities) {
ImmutableArray<Component> components = e.getComponents();
for (Component component : components) {
if (!(component instanceof Disposable)) continue;
Disposable disposable = (Disposable) component;
disposable.dispose();
Gdx.app.log("Disposed", disposable.toString());
}
}
}
}
public class DrawingComponent implements Component, Disposable {
public Sprite sprite = new Sprite();
public void dispose() {
sprite.getTexture().dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment