-
Notifications
You must be signed in to change notification settings - Fork 112
Component
Daan van Yperen edited this page Sep 27, 2015
·
32 revisions
Components are pure data classes with optionally some helper methods.
public class Health extends Component {
public int health;
public int damage;
}
Components are added/fetched and removed from entities using component mappers. Component mappers are high performance component accessors and mutators.
In these example we use ComponentMapper<Pos> mPos;
Adds component to entity, or returns pre-existing.
Pos pos = mPos.create(myEntity);
Removes component from entity, does nothing if it lacks given component.
Pos pos = mPos.remove(myEntity);
Returns true
if part of entity composition.
if ( mPos.has(myEntity) ) { .. }
Toggle component. Especially useful for empty tagging components (example: Flaming
Invisible
etc).
mPos.set(myEntity,true); // add (if missing)
mPos.set(myEntity,false); // remove (if missing)
Do you target platforms that suffer from garbage collection freezes? pool your components!
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference