Projectile Animations - UQcsse3200/2024-studio-1 GitHub Wiki

Overview

ProjectileAnimationController is a component that manages the animation states of a projectile entity. It listens for specific events triggered by the entity and responds by playing the corresponding animations, such as firing projectiles. The class handles directional animations by adjusting the animation based on the entity's facing direction (e.g., left or right).

Class Members

  • AnimationRenderComponent animator: The animator component responsible for handling and rendering the animations.
  • DirectionalNPCComponent directionalComponent: A component that tracks the direction (left or right) the projectile is facing.

Key Methods:

  1. create()
  • Called when the component is initialized.
  • Retrieves the necessary components (AnimationRenderComponent and DirectionalNPCComponent) from the entity.
  • Registers listeners for specific events like "fire_attack", "fire1", and "fire2"

Usage:

This class is essential for animating projectiles in a game, particularly in cases where projectiles need to display different animations depending on the direction they are fired (e.g., left or right). It ensures smooth transitions between different animation states by listening for events and playing the appropriate animation based on the projectile type and direction.