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

UI element that manages and plays multiple flipbook animations. More...

#include <AnimatorElement.h>

Inheritance diagram for clt::AnimatorElement:
clt::FlipbookElement clt::SpriteElement clt::WidgetElement

Public Member Functions

 AnimatorElement (std::string pAnimName, const std::vector< Texture * > &pTextures, bool pLooping=true, float pAnimFps=24, Vector2 pSize={ 1.0f, 1.0f }, Vector2 pPosition={ 0.0f, 0.0f }, int zOrder=0)
 Constructs an AnimatorElement with an initial animation.
 
 AnimatorElement ()=delete
 Deleted default constructor.
 
 AnimatorElement (const FlipbookElement &)=delete
 Deleted copy constructor from FlipbookElement.
 
AnimatorElementoperator= (const FlipbookElement &)=delete
 Deleted assignment operator from FlipbookElement.
 
virtual ~AnimatorElement ()
 Destructor.
 
void AddNewAnim (std::string pAnimName, const std::vector< Texture * > &pTextures, bool pLooping=true, float pAnimFps=24, int pDrawOrder=100)
 Adds a new animation to the animator.
 
void PlayAnim (std::string pAnimName)
 Plays the animation with the given name.
 
void RemoveAnim (std::string pAnimName)
 Removes the animation with the given name.
 
FlipbookElementGetAnim (std::string pAnimName)
 Gets the FlipbookElement for the given animation name.
 
- Public Member Functions inherited from clt::FlipbookElement
 FlipbookElement ()=delete
 Deleted default constructor.
 
 FlipbookElement (const std::vector< Texture * > pTexture, bool pLooping=true, float pAnimFps=24, Vector2 size={ 1.0f, 1.0f }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a FlipbookElement.
 
std::vector< Texture * > GetFlipbookTextures () const
 Gets the flipbook textures.
 
bool GetLooping () const
 Gets whether the animation is looping.
 
void SetFlipbookTextures (const std::vector< Texture * > pTextures)
 Sets the flipbook textures.
 
void SetFlipbookFps (float pFps)
 Sets the animation FPS.
 
void SetLooping (bool pLooping)
 Sets whether the animation should loop.
 
float GetFlipbookFps () const
 Gets the animation FPS.
 
void Play ()
 Plays the animation (unpauses).
 
void PlayFromStart ()
 Plays the animation from the start.
 
void Pause ()
 Pauses the animation.
 
void Toggle ()
 Toggles the paused state of the animation.
 
virtual void Update () override
 Updates the animation state. Should be called every frame.
 
- Public Member Functions inherited from clt::SpriteElement
 SpriteElement (const std::string textureName, Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a SpriteElement with a texture name, size, position, and Z order.
 
 SpriteElement (Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a SpriteElement with size, position, and Z order. No texture is set.
 
 SpriteElement (Texture *texture, Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a SpriteElement with a texture pointer, size, position, and Z order.
 
 ~SpriteElement ()=default
 Destructor for SpriteElement.
 
virtual Transform2D GetTransform () const override
 Gets the transform of the sprite element.
 
virtual Vector2 GetSize () const override
 Gets the size of the sprite element.
 
virtual void Draw (RendererGL *renderer) override
 Draws the sprite element using the provided renderer.
 
void SetTexture (Texture *pTexture)
 Sets the texture for the sprite element.
 
void SetTexture (std::string pTexture)
 Sets the texture for the sprite element by texture name.
 
TextureGetTexture () const
 Gets the current texture of the sprite element.
 
- Public Member Functions inherited from clt::WidgetElement
 WidgetElement (Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a WidgetElement with given size, position, and Z-order.
 
 ~WidgetElement ()=default
 Default destructor.
 
int GetZOrder () const
 Gets the Z-order of the widget.
 
void SetZOrder (int ZOrder)
 Sets the Z-order and updates the widget order in the owner panel.
 
Vector2 GetPosition () const
 Gets the position of the widget.
 
float GetRotation () const
 Gets the rotation of the widget.
 
void SetSize (Vector2 size)
 Sets the size of the widget.
 
void SetSize (float size)
 Sets the size of the widget (uniform scale).
 
void SetAnchor (Anchor anchor)
 Sets the anchor type for the widget.
 
void SetPosition (Vector2 position)
 Sets the position of the widget.
 
void SetRotation (float rotation)
 Sets the rotation of the widget.
 
void ToggleVisibility ()
 Toggles the visibility of the widget.
 

Additional Inherited Members

- Public Attributes inherited from clt::WidgetElement
bool mVisibility
 
- Protected Member Functions inherited from clt::WidgetElement
void SetOwner (UIPanel *pOwner)
 Sets the owner UIPanel of this widget.
 
- Protected Attributes inherited from clt::SpriteElement
TexturemTexture
 Pointer to the texture used by this sprite element.
 
- Protected Attributes inherited from clt::WidgetElement
Transform2D mTransform
 
friend UIPanel
 

Detailed Description

UI element that manages and plays multiple flipbook animations.

AnimatorElement allows adding, removing, and switching between named flipbook animations.

Constructor & Destructor Documentation

◆ AnimatorElement()

AnimatorElement::AnimatorElement ( std::string pAnimName,
const std::vector< Texture * > & pTextures,
bool pLooping = true,
float pAnimFps = 24,
Vector2 pSize = { 1.0f, 1.0f },
Vector2 pPosition = { 0.0f, 0.0f },
int zOrder = 0 )

Constructs an AnimatorElement with an initial animation.

Parameters
pAnimNameName of the initial animation.
pTexturesTextures for the initial animation.
pLoopingWhether the animation should loop.
pAnimFpsFrames per second for the animation.
pSizeSize of the element.
pPositionPosition of the element.
zOrderZ-order for rendering.

Member Function Documentation

◆ AddNewAnim()

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

Adds a new animation to the animator.

Parameters
pAnimNameName of the animation.
pTexturesTextures for the animation.
pLoopingWhether the animation should loop.
pAnimFpsFrames per second for the animation.
pDrawOrderDraw order for the animation.

◆ GetAnim()

FlipbookElement * clt::AnimatorElement::GetAnim ( std::string pAnimName)
inline

Gets the FlipbookElement for the given animation name.

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

◆ PlayAnim()

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

Plays the animation with the given name.

Parameters
pAnimNameName of the animation to play.

◆ RemoveAnim()

void AnimatorElement::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: