Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::AnimatorComponent Class Reference

AnimatorComponent manages multiple FlipbookComponent animations and allows switching between them. More...

#include <AnimatorComponent.h>

Inheritance diagram for clt::AnimatorComponent:
clt::FlipbookComponent clt::SpriteComponent clt::Component Dir8Sprite

Public Member Functions

 AnimatorComponent (std::string pAnimName, const std::vector< Texture * > &pTextures, bool pLooping=true, int pDrawOrder=100)
 Constructs an AnimatorComponent with an initial animation from a vector of textures.
 
 AnimatorComponent (std::string pAnimName, Texture *pTexture, bool pLooping=true, int pDrawOrder=100)
 Constructs an AnimatorComponent with an initial animation from a single texture.
 
 AnimatorComponent (const FlipbookComponent &)=delete
 
AnimatorComponentoperator= (const FlipbookComponent &)=delete
 
virtual ~AnimatorComponent ()
 Destructor for AnimatorComponent. Cleans up allocated animations.
 
void AddNewAnim (std::string pAnimName, const std::vector< Texture * > &pTextures, bool pLooping=true, int pDrawOrder=100)
 Adds a new animation from a vector of textures.
 
void AddNewAnim (std::string pAnimName, Texture *pTexture, bool pLooping=true, int pDrawOrder=100)
 Adds a new animation from a single texture.
 
void PlayAnim (std::string pAnimName)
 Plays the animation with the given name.
 
void RemoveAnim (std::string pAnimName)
 Removes the animation with the given name.
 
FlipbookComponentGetAnim (std::string pAnimName)
 Gets the FlipbookComponent for the given animation name.
 
- Public Member Functions inherited from clt::FlipbookComponent
 FlipbookComponent (const std::vector< Texture * > &pTexture, bool pLooping=true, int pDrawOrder=100)
 Constructs a FlipbookComponent with the given textures, looping option, and draw order.
 
 FlipbookComponent ()=delete
 Deleted default constructor.
 
 FlipbookComponent (const FlipbookComponent &)=delete
 Deleted copy constructor.
 
FlipbookComponentoperator= (const FlipbookComponent &)=delete
 Deleted copy assignment operator.
 
virtual ~FlipbookComponent ()
 Destructor.
 
virtual void SetOwner (Actor *pOwner) override
 Sets the owner actor for this component and initializes the texture.
 
float GetFlipbookFps () const
 Gets the current animation frame rate (FPS).
 
void SetFlipbookTextures (const std::vector< Texture * > pTextures)
 Sets the textures used for the flipbook animation.
 
void SetFlipbookFps (float pFps)
 Sets the animation frame rate (FPS).
 
void SetLooping (bool pLooping)
 Sets whether the animation should loop.
 
std::vector< Texture * > GetFlipbookTextures () const
 Gets the textures used for the flipbook animation.
 
bool GetLooping () const
 Checks if the animation is set to loop.
 
void Play ()
 Starts or resumes the animation.
 
void Pause ()
 Pauses the animation.
 
void Toggle ()
 Toggles the paused state of the animation.
 
void Update () override
 Updates the animation frame. Should be called every frame.
 
- Public Member Functions inherited from clt::SpriteComponent
 SpriteComponent (Texture *pTexture, int DrawOrder=0)
 Constructs a SpriteComponent with the given texture and draw order.
 
 SpriteComponent ()=delete
 
 SpriteComponent (const SpriteComponent &)=delete
 
SpriteComponentoperator= (const SpriteComponent &)=delete
 
virtual ~SpriteComponent ()
 Destructor. Removes this component from the renderer if it has an owner.
 
virtual void SetTexture (Texture *pTexture)
 Sets the texture for this sprite.
 
virtual void SetTexture (const std::string &pTexture)
 Sets the texture for this sprite by name or path.
 
void SetFlipX (bool pFlip)
 Sets whether the sprite is flipped horizontally.
 
void SetFlipY (bool pFlipY)
 Sets whether the sprite is flipped vertically.
 
bool GetFlipX () const
 Gets whether the sprite is flipped horizontally.
 
bool GetFlipY () const
 Gets whether the sprite is flipped vertically.
 
int GetTexWidth () const
 Gets the width of the texture.
 
int GetTexHeight () const
 Gets the height of the texture.
 
TextureGetTexture () const
 Gets the texture used by this sprite.
 
- Public Member Functions inherited from clt::Component
 Component (int pUpdateOrder=0)
 Constructor for Component.
 
virtual ~Component ()=default
 Virtual destructor for Component.
 
virtual void Start ()
 Called when the component is started.
 
virtual void Destroy ()
 Called to destroy the component.
 
void SetActive (bool pActive)
 Enables or disables the component.
 
void OnDestroy ()
 Called when the component is destroyed.
 
bool IsActive () const
 Checks if the component is enabled.
 
int GetUpdateOrder () const
 Gets the update order of the component.
 
void SetRelativeLocation (const Vector3 &loc)
 Sets the relative location of the component.
 
void SetRelativeLocation (const Vector2 &loc)
 Sets the relative location of the component.
 
void SetWorldLocation (const Vector3 &loc)
 Sets the world location of the component.
 
void SetRelativeScale (const Vector3 &scale)
 Sets the relative scale of the component.
 
void SetRelativeScale (const Vector2 &scale)
 Sets the relative scale of the component.
 
void SetRelativeRotation (Quaternion rot)
 Sets the relative rotation of the component.
 
void SetRelativeRotation (Vector3 rot)
 Sets the relative rotation of the component.
 
void SetWorldRotation (const Quaternion &rot)
 Sets the world rotation of the component.
 
void SetWorldRotation (const Vector3 &rot)
 Sets the world rotation of the component.
 
void AddRelativeRotation (Vector3 rot)
 Adds a rotation to the current relative rotation.
 
void SetRelativeRotation (float rot)
 Sets the relative rotation of the component.
 
void SetRelativeTransform (Transform &transform)
 Sets the relative transform of the component.
 
Vector3 GetRelativeLocation () const
 Gets the relative location of the component.
 
Vector3 GetRelativeScale () const
 Gets the relative scale of the component.
 
Quaternion GetRelativeRotation () const
 Gets the relative rotation of the component.
 
Vector3 GetRelativeRotationEuler () const
 Gets the relative rotation of the component as Euler angles.
 
Transform GetRelativeTransform () const
 Gets the relative transform of the component.
 
Vector3 GetWorldLocation () const
 Gets the world location of the component.
 
Vector3 GetWorldScale () const
 Gets the world scale of the component.
 
Quaternion GetWorldRotation () const
 Gets the world rotation of the component.
 
virtual Transform GetWorldTransform () const
 Gets the world transform of the component.
 
ActorGetOwner () const
 Gets the owner actor of this component.
 

Additional Inherited Members

- Public Attributes inherited from clt::Component
friend Actor
 
- Protected Member Functions inherited from clt::Component
bool LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false)
 Performs a line trace (raycast) using the owning actor.
 
- Protected Attributes inherited from clt::SpriteComponent
int mTexWidth
 
int mTexHeight
 
bool mFlipX
 
bool mFlipY
 
TexturemTexture
 
- Protected Attributes inherited from clt::Component
bool mIsActive = true
 Indicates if the component is active.
 
int mUpdateOrder = 0
 The order in which the component is updated.
 
ActormOwner
 The actor that owns this component.
 
Transform mRelativeTransform
 The relative transform of the component to its owner.
 

Detailed Description

AnimatorComponent manages multiple FlipbookComponent animations and allows switching between them.

Constructor & Destructor Documentation

◆ AnimatorComponent() [1/2]

AnimatorComponent::AnimatorComponent ( std::string pAnimName,
const std::vector< Texture * > & pTextures,
bool pLooping = true,
int pDrawOrder = 100 )

Constructs an AnimatorComponent with an initial animation from a vector of textures.

Parameters
pAnimNameName of the animation.
pTexturesVector of textures for the animation.
pLoopingWhether the animation should loop.
pDrawOrderDraw order for rendering.

◆ AnimatorComponent() [2/2]

AnimatorComponent::AnimatorComponent ( std::string pAnimName,
Texture * pTexture,
bool pLooping = true,
int pDrawOrder = 100 )

Constructs an AnimatorComponent with an initial animation from a single texture.

Parameters
pAnimNameName of the animation.
pTextureTexture for the animation.
pLoopingWhether the animation should loop.
pDrawOrderDraw order for rendering.

Member Function Documentation

◆ AddNewAnim() [1/2]

void AnimatorComponent::AddNewAnim ( std::string pAnimName,
const std::vector< Texture * > & pTextures,
bool pLooping = true,
int pDrawOrder = 100 )

Adds a new animation from a vector of textures.

Parameters
pAnimNameName of the animation.
pTexturesVector of textures for the animation.
pLoopingWhether the animation should loop.
pDrawOrderDraw order for rendering.

◆ AddNewAnim() [2/2]

void AnimatorComponent::AddNewAnim ( std::string pAnimName,
Texture * pTexture,
bool pLooping = true,
int pDrawOrder = 100 )

Adds a new animation from a single texture.

Parameters
pAnimNameName of the animation.
pTextureTexture for the animation.
pLoopingWhether the animation should loop.
pDrawOrderDraw order for rendering.

◆ GetAnim()

FlipbookComponent * clt::AnimatorComponent::GetAnim ( std::string pAnimName)
inline

Gets the FlipbookComponent for the given animation name.

Parameters
pAnimNameName of the animation.
Returns
Pointer to the FlipbookComponent, or nullptr if not found.

◆ PlayAnim()

void AnimatorComponent::PlayAnim ( std::string pAnimName)

Plays the animation with the given name.

Parameters
pAnimNameName of the animation to play.

◆ RemoveAnim()

void AnimatorComponent::RemoveAnim ( std::string pAnimName)

Removes the animation with the given name.

Parameters
pAnimNameName of the animation to remove.

The documentation for this class was generated from the following files: