-
Notifications
You must be signed in to change notification settings - Fork 112
Component
Daan van Yperen edited this page Sep 28, 2015
·
32 revisions
Components are pure data classes with optionally some helper methods.
See Component best practices, Example component.
Components are added/fetched and removed from entities using Component mappers.
In these examples we use ComponentMapper<Position> mPosition;
Adds component to entity, or returns pre-existing.
Position position = mPosition.create(myEntity);
position.x = 10;
Alternatively see #get(myEntity)
and getSafe(myEntity[,default])
.
Removes component from entity, does nothing if it lacks given component.
mPosition.remove(myEntity);
Returns true
if part of entity composition.
if ( mPosition.has(myEntity) ) { .. }
Toggle component. Especially useful for empty tagging components (example: Flaming
Invisible
etc).
mPosition.set(myEntity,true); // add (if missing)
mPosition.set(myEntity,false); // remove (if exists)
Does your target platform suffer from garbage collection freezes? pool your components!
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference