Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::TextureAnimationComponent Struct Reference

Animates through a series of sub textures. More...

#include <Components.h>

Public Member Functions

 TextureAnimationComponent ()=default
 TextureAnimationComponent (const TextureAnimationComponent &)=default
 TextureAnimationComponent (const std::vector< Ref< SubTexture2D > > &subTextures, float frameTime)
 Constructor that initializes the sub-textures and frame time.
 operator std::vector< Ref< SubTexture2D > > & ()
 operator const std::vector< Ref< SubTexture2D > > & () const
std::vector< Ref< SubTexture2D > > & GetSubTextures ()
uint32_t GetCurrentFrame () const
 Returns the index of the current frame.
void Update (float deltaTime)
 Updates the animation based on the elapsed time.

Public Attributes

std::vector< Ref< SubTexture2D > > SubTextures
 The list of sub-textures for the animation.
uint32_t CurrentFrame = 0
 The current frame index.
float FrameTime = 0.6f
 Time per frame in seconds.
float TimeAccumulator = 0.0f
 Accumulated time for frame switching.

Detailed Description

Animates through a series of sub textures.

(can be used with full textures)

Constructor & Destructor Documentation

◆ TextureAnimationComponent() [1/3]

Vesper::TextureAnimationComponent::TextureAnimationComponent ( )
default

◆ TextureAnimationComponent() [2/3]

Vesper::TextureAnimationComponent::TextureAnimationComponent ( const TextureAnimationComponent & )
default

◆ TextureAnimationComponent() [3/3]

Vesper::TextureAnimationComponent::TextureAnimationComponent ( const std::vector< Ref< SubTexture2D > > & subTextures,
float frameTime )
inline

Constructor that initializes the sub-textures and frame time.

Parameters
subTexturesVector of sub-textures for the animation.
frameTimeTime per frame in seconds.
182 : SubTextures(subTextures), FrameTime(frameTime) {
183 }
std::vector< Ref< SubTexture2D > > SubTextures
The list of sub-textures for the animation.
Definition Components.h:167
float FrameTime
Time per frame in seconds.
Definition Components.h:171

Member Function Documentation

◆ GetCurrentFrame()

uint32_t Vesper::TextureAnimationComponent::GetCurrentFrame ( ) const
inline

Returns the index of the current frame.

190{ return CurrentFrame; }
uint32_t CurrentFrame
The current frame index.
Definition Components.h:169

◆ GetSubTextures()

std::vector< Ref< SubTexture2D > > & Vesper::TextureAnimationComponent::GetSubTextures ( )
inline
187{ return SubTextures; }

◆ operator const std::vector< Ref< SubTexture2D > > &()

Vesper::TextureAnimationComponent::operator const std::vector< Ref< SubTexture2D > > & ( ) const
inline
185{ return SubTextures; }

◆ operator std::vector< Ref< SubTexture2D > > &()

Vesper::TextureAnimationComponent::operator std::vector< Ref< SubTexture2D > > & ( )
inline
184{ return SubTextures; }

◆ Update()

void Vesper::TextureAnimationComponent::Update ( float deltaTime)
inline

Updates the animation based on the elapsed time.

Parameters
deltaTimeThe elapsed time since the last update.
195 {
196 if (SubTextures.empty() || FrameTime <= 0.0f)
197 return;
198
199 TimeAccumulator += deltaTime;
200 while (TimeAccumulator >= FrameTime) {
201 CurrentFrame = (CurrentFrame + 1) % static_cast<uint32_t>(SubTextures.size());
203 }
204 }
float TimeAccumulator
Accumulated time for frame switching.
Definition Components.h:173

Member Data Documentation

◆ CurrentFrame

uint32_t Vesper::TextureAnimationComponent::CurrentFrame = 0

The current frame index.

◆ FrameTime

float Vesper::TextureAnimationComponent::FrameTime = 0.6f

Time per frame in seconds.

◆ SubTextures

std::vector<Ref<SubTexture2D> > Vesper::TextureAnimationComponent::SubTextures

The list of sub-textures for the animation.

◆ TimeAccumulator

float Vesper::TextureAnimationComponent::TimeAccumulator = 0.0f

Accumulated time for frame switching.


The documentation for this struct was generated from the following file: