Skip to content

Instantly share code, notes, and snippets.

@ronjunevaldoz
Last active August 5, 2016 04:28
Show Gist options
  • Save ronjunevaldoz/c23be030b06472baf90f3c2b771bb1c2 to your computer and use it in GitHub Desktop.
Save ronjunevaldoz/c23be030b06472baf90f3c2b771bb1c2 to your computer and use it in GitHub Desktop.
libgdx ashley ecs tips & tricks
TIPS
- before removing entity be sure the components data arrays or maps are cleared
example 1 solution:
entity.removeAll(); // before using removeAll() check if the components data has arrays or maps
SpriteComponent sprite = Mapper.sprite.get(entity);
sprite.clear(); // to avoid leaving traces of unneccesary texture traces
entity.remove(SpriteComponents.class);
SpriteComponent implements Component {
public Array<Sprite sprite;
}
example 2 solution
SpriteComponent implements Componenet, Poolable {
@Override
public void reset() {
// clear your arrays, maps or data
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment