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

UI element for displaying animated flipbook sprites. More...

#include <FlipbookElement.h>

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

Public Member Functions

 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 for displaying animated flipbook sprites.

FlipbookElement manages a sequence of textures to create a frame-by-frame animation. It supports looping, pausing, and FPS control.

Constructor & Destructor Documentation

◆ FlipbookElement()

clt::FlipbookElement::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 )
inline

Constructs a FlipbookElement.

Parameters
pTextureVector of textures for the flipbook animation.
pLoopingWhether the animation should loop.
pAnimFpsAnimation frames per second.
sizeSize of the element.
positionPosition of the element.
ZOrderZ-order for rendering.

Member Function Documentation

◆ GetFlipbookFps()

float clt::FlipbookElement::GetFlipbookFps ( ) const
inline

Gets the animation FPS.

Returns
Frames per second.

◆ GetFlipbookTextures()

std::vector< Texture * > clt::FlipbookElement::GetFlipbookTextures ( ) const
inline

Gets the flipbook textures.

Returns
Vector of Texture pointers.

◆ GetLooping()

bool clt::FlipbookElement::GetLooping ( ) const
inline

Gets whether the animation is looping.

Returns
True if looping, false otherwise.

◆ SetFlipbookFps()

void clt::FlipbookElement::SetFlipbookFps ( float pFps)
inline

Sets the animation FPS.

Parameters
pFpsFrames per second.

◆ SetFlipbookTextures()

void FlipbookElement::SetFlipbookTextures ( const std::vector< Texture * > pTextures)

Sets the flipbook textures.

Parameters
pTexturesVector of Texture pointers.

◆ SetLooping()

void clt::FlipbookElement::SetLooping ( bool pLooping)
inline

Sets whether the animation should loop.

Parameters
pLoopingTrue to enable looping.

◆ Update()

void FlipbookElement::Update ( )
overridevirtual

Updates the animation state. Should be called every frame.

Reimplemented from clt::SpriteElement.


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