-
Notifications
You must be signed in to change notification settings - Fork 4
DroidAnimationController
The DroidAnimationController
is a specialized game component designed to manage and trigger animations for the DroidTower entity. This class listens to a variety of events that correspond to different states of the DroidTower such as walking, aiming, attacking, and dying. The actual triggering of these events is managed by DroidCombatTask
To make use of the DroidAnimationController
, you must first attach this component to a DroidTower entity. Below is a Java code snippet demonstrating this process:
DroidAnimationController animationController = new DroidAnimationController();
droidTowerEntity.addComponent(animationController);
Additionally, an AnimationRenderComponent
is required for the controller to function. Here's how to add it:
TextureAtlas textureAtlas = ServiceLocator.getResourceService().getAsset(DROID_ATLAS, TextureAtlas.class);
AnimationRenderComponent animator = new AnimationRenderComponent(textureAtlas);
droidTowerEntity.addComponent(animator);
The DroidAnimationController
listens for events like "walkStart", "attackUpStart", "goDownStart", etc., which are triggered by other components. When an event is triggered, it initiates the corresponding animation on the DroidTower entity.
Here is the general way the controller listens for events:
entity.getEvents().addListener("<EventName>", this::<MethodName>);
- Event Listener:
this::animateWalk
- Sprite Sheet: Multiple frames for walking animation
- Event Listeners:
this::animateGoUp
andthis::animateGoDown
- Sprite Sheet: Single frame for aiming up and down
- Event Listeners:
this::animateAttackUp
andthis::animateAttackDown
- Sprite Sheet: Multiple frames for attacking animations while aiming up or down
- Event Listener:
this::animateDeath
- Sprite Sheet: Multiple frames for death animation
- Ensure an
AnimationRenderComponent
is initialized and added to the entity before attachingDroidAnimationController
. - Clearly specify your animation states in the
AnimationRenderComponent
for smooth transitions between animations. - Make sure the event names used in the combat logic component and
DroidAnimationController
are synchronized to maintain cohesive gameplay logic and animations.
Please refer to the DroidAnimationController Test Plan
for detailed test cases and methodologies.