-
Notifications
You must be signed in to change notification settings - Fork 4
Patrick Animation Controller
The PatrickAnimationController
is a specialized game component designed to manage and trigger animations for the Patrick Boss entity. This class listens to a variety of events that correspond to different states of the Patrick Boss such as walking, attacking, and dying. The actual triggering of these events is managed by Patrick Task.
To make use of the PatrickAnimationController
, you must first attach this component to a Patrick Boss entity. Below is a Java code snippet demonstrating this process:
PatrickAnimationController animationController = new PatrickAnimationController();
patrick.addComponent(animationController);
Additionally, an AnimationRenderComponent
is required for the controller to function. Here's how to add it:
private static final String PATRICK_ATLAS = "images/mobboss/patrick.atlas";
TextureAtlas textureAtlas = ServiceLocator.getResourceService().getAsset(PATRICK_ATLAS, TextureAtlas.class);
AnimationRenderComponent animator = new AnimationRenderComponent(textureAtlas);
patrick.addComponent(animator);
The PatrickAnimationController
listens for events like "patrick_attack", "patrick_walk", "patrick_death", etc., which are triggered by other components. When an event is triggered, it initiates the corresponding animation on the Patrick Boss entity.
Here is the general way the controller listens for events:
entity.getEvents().addListener("<EventName>", this::<MethodName>);
- Ensure an
AnimationRenderComponent
is initialized and added to the entity before attachingPatrickAnimationController
. - Clearly specify your animation states in the
AnimationRenderComponent
for smooth transitions between animations. - Make sure the event names used in the task logic component and
PatrickAnimationController
are synchronized to maintain cohesive gameplay logic and animations.