Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
AnimatedSpriteRenderComponent Class Reference

AnimatedSpriteRenderComponent extends SpriteRenderComponent to support frame-based 2D sprite animations using a sequence of textures. More...

#include <AnimatedSpriteRenderComponent.h>

Inheritance diagram for AnimatedSpriteRenderComponent:
SpriteRenderComponent RenderComponent Component

Public Member Functions

 AnimatedSpriteRenderComponent (Actor *pOwner, int pDrawOrder=100)
 Constructs an animated sprite component with an optional draw order.
 
virtual ~AnimatedSpriteRenderComponent ()
 Destructor for the animated sprite component.
 
 AnimatedSpriteRenderComponent ()=delete
 
 AnimatedSpriteRenderComponent (const AnimatedSpriteRenderComponent &)=delete
 
AnimatedSpriteRenderComponentoperator= (const AnimatedSpriteRenderComponent &)=delete
 
void SetAnimationFps (float pFps)
 Sets the frame rate (FPS) for the animation.
 
void SetCurrentAnimation (std::string pAnimation)
 Changes the current animation to play, by name. If the animation is not found, it has no effect.
 
void AddAnimation (std::string pName, std::vector< Texture * > pTextures)
 Adds a new animation consisting of a name and a sequence of textures.
 
void Update () override
 Updates the animation by progressing the current frame based on time.
 
float GetAnimationFps () const
 Gets the currently configured animation FPS.
 
- Public Member Functions inherited from SpriteRenderComponent
 SpriteRenderComponent (Actor *pOwner, int pDrawOrder=100)
 Constructs a sprite render component without a texture.
 
 SpriteRenderComponent (Actor *pOwner, Texture *pTexture, int pDrawOrder=100)
 Constructs a sprite render component with an initial texture.
 
 SpriteRenderComponent ()=delete
 
 SpriteRenderComponent (const SpriteRenderComponent &)=delete
 
SpriteRenderComponentoperator= (const SpriteRenderComponent &)=delete
 
virtual void SetTexture (Texture *pTexture)
 Sets or updates the texture used by this sprite. Also updates internal texture dimensions.
 
virtual void Render (IRenderer *pRenderer) override
 Renders the sprite using the provided renderer. Applies flip settings and position based on the rectangle.
 
RenderType GetRenderType () override
 Returns the render type of this component (Viewport).
 
void SetNewDimensions (float x, float y)
 Sets new dimensions (width and height) for the sprite's rectangle.
 
void SetNewPositions (float x, float y)
 Sets a new position (x, y) for the sprite's rectangle.
 
int GetDrawOrder () const override
 Gets the drawing order priority of this component. Higher values render on top of lower values.
 
int GetTexWidth () const
 Gets the width of the texture used by this sprite.
 
int GetTexHeight () const
 Gets the height of the texture used by this sprite.
 
- Public Member Functions inherited from RenderComponent
 RenderComponent (Actor *pOwner)
 Constructs the RenderComponent and assigns it to the owning Actor.
 
void OnStart () override
 Called when the component is started. Registers the component with the scene's renderer for drawing.
 
void OnEnd () override
 Called when the component is removed or destroyed. Unregisters the component from the renderer.
 
- Public Member Functions inherited from Component
 Component (Actor *pOwner, int pUpdateOrder=100)
 Constructor for Component.
 
virtual ~Component ()
 
virtual void OnUpdateWorldTrandform ()
 Called when the world transform of the actor is updated. This allows the component to react to changes in the actor's world transform.
 
void SetActive (bool isActive)
 Sets the active status of the component.
 
void SetOwner (Actor *pOwner)
 Sets the actor that owns this component.
 
int GetUpdateOrder () const
 Returns the update order of the component. Components with lower update orders are updated first.
 
ActorGetOwner () const
 Returns the actor that owns this component.
 

Additional Inherited Members

- Public Attributes inherited from SpriteRenderComponent
Rectangle mRectangle { Vector2(-16,-16),Vector2(32,32) }
 The rectangle defining sprite position and size, relative to the actor.
 
IRenderer::Flip mFlip = IRenderer::Flip::None
 Flip mode (none, horizontal, vertical, both) for sprite rendering.
 
- Public Attributes inherited from RenderComponent
Color mColor { 255,255,255,255 }
 
- Protected Attributes inherited from SpriteRenderComponent
TexturemTexture
 The texture used for rendering this sprite.
 
int mDrawOrder
 Drawing order priority.
 
int mTexWidth
 Internal texture width (updated with SetTexture).
 
int mTexHeight
 Internal texture height (updated with SetTexture).
 
- Protected Attributes inherited from Component
ActormOwner = nullptr
 The actor that owns this component.
 

Detailed Description

AnimatedSpriteRenderComponent extends SpriteRenderComponent to support frame-based 2D sprite animations using a sequence of textures.

Constructor & Destructor Documentation

◆ AnimatedSpriteRenderComponent() [1/3]

AnimatedSpriteRenderComponent::AnimatedSpriteRenderComponent ( Actor * pOwner,
int pDrawOrder = 100 )

Constructs an animated sprite component with an optional draw order.

Parameters
pOwnerThe actor that owns this component.
pDrawOrderDrawing priority (higher values render later).

◆ ~AnimatedSpriteRenderComponent()

AnimatedSpriteRenderComponent::~AnimatedSpriteRenderComponent ( )
virtual

Destructor for the animated sprite component.

◆ AnimatedSpriteRenderComponent() [2/3]

AnimatedSpriteRenderComponent::AnimatedSpriteRenderComponent ( )
delete

◆ AnimatedSpriteRenderComponent() [3/3]

AnimatedSpriteRenderComponent::AnimatedSpriteRenderComponent ( const AnimatedSpriteRenderComponent & )
delete

Member Function Documentation

◆ AddAnimation()

void AnimatedSpriteRenderComponent::AddAnimation ( std::string pName,
std::vector< Texture * > pTextures )

Adds a new animation consisting of a name and a sequence of textures.

Parameters
pNameName identifier for the animation.
pTexturesVector of textures forming the animation frames.

◆ GetAnimationFps()

float AnimatedSpriteRenderComponent::GetAnimationFps ( ) const

Gets the currently configured animation FPS.

Returns
Frames per second (float).

◆ operator=()

AnimatedSpriteRenderComponent & AnimatedSpriteRenderComponent::operator= ( const AnimatedSpriteRenderComponent & )
delete

◆ SetAnimationFps()

void AnimatedSpriteRenderComponent::SetAnimationFps ( float pFps)

Sets the frame rate (FPS) for the animation.

Parameters
pFpsFrames per second.

◆ SetCurrentAnimation()

void AnimatedSpriteRenderComponent::SetCurrentAnimation ( std::string pAnimation)

Changes the current animation to play, by name. If the animation is not found, it has no effect.

Parameters
pAnimationName of the animation to play.

◆ Update()

void AnimatedSpriteRenderComponent::Update ( )
overridevirtual

Updates the animation by progressing the current frame based on time.

Reimplemented from Component.


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