-
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:
private static final String DROID_ATLAS = "images/towers/DroidTower.atlas";
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::animateDefault
- Sprite Sheet: Single frame for the idle state
- Event Listener:
this::animateWalk
- Sprite Sheet: 6 frames for walking animation
- Event Listeners:
this::animateGoUp
andthis::animateGoDown
- Sprite Sheet: 10 frames in total for aiming up and down
- Event Listeners:
this::animateAttackUp
andthis::animateAttackDown
- Sprite Sheet: 11 frames in total for attacking animations while aiming up or down
- Event Listener:
this::animateDeath
- Sprite Sheet: 9 frames for death animation
- The shooting logic is temporarily implemented within this component. In future releases, this functionality may be moved to a separate component that enables an entity to fire projectiles.
- 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.