-
Notifications
You must be signed in to change notification settings - Fork 6
Accessing components
In this example an Entity has a Sprite. We try to grab it back out of the Entity. Sometimes, you can assume there is a class of given type in the Entity (based on your code architecture), but to be sure it is really there, you could do a null-check. Alternatively you can also choose to check with entity.has(Sprite)
.
var sprite = myEntity.get(Sprite);
if (sprite != null)
{
trace('sprite found in entity: $sprite');
}
else
{
trace('Warn: No sprite found.');
}
The fun part of this, is that you can swap the actual Sprite with any other Sprite (like FillSprite
, ImageSprite
, PatternSprite
etc..). If you still use entity.get(Sprite)
, it returns that sprite. That allows you to create loose assumptions, which gives some flexibility.
Documentation guide for Flambe - Targeted to version 4.0+
Flambe | Installation | Demo projects | Showcase | API Reference | Forum
Flambe is MIT licensed and available for free. Feel free to contribute!
- Home / Installation
- Entity / Components
- Core
- Assets
- Publish your game
- Other
- Editors
- Plugins, tools, extensions
- Help
- More Flambe