Vigilante Game Framework  1.0.0.8
A 2D/3D C++ Game Framework using SFML.
Public Member Functions | List of all members
VAnimation Class Reference

Handler for a single sprite based frame animation. More...

#include <VAnimation.h>

Public Member Functions

 VAnimation (const std::vector< int > &Frames, float FramesPerSecond, bool Looping, bool Reverse)
 
void Reset (std::function< void()> onComplete=nullptr)
 
void SetCurrentFrame (int NewFrame)
 
int GetCurrentFrame ()
 
int GetFrameCount ()
 
void SetLooping (bool Looping)
 
void SetReverse (bool Reverse)
 
void Update (float dt)
 

Detailed Description

Handler for a single sprite based frame animation.

Constructor & Destructor Documentation

◆ VAnimation()

VAnimation::VAnimation ( const std::vector< int > &  Frames,
float  FramesPerSecond,
bool  Looping,
bool  Reverse 
)
Parameters
FramesThe list of Frames the animation will have, you can pass in an std::vector<int> object or an array of ints using braces (e.g. { 0, 3, 7, 8 }).
FramesPerSecondThe amount of frames to play per second in time. This gets converted to a frameDelay using 1 / FramesPerSecond. Must be greater than 0.
LoopingWhether the animation should loop or not.
ReverseWhether the animation should reverse or not.

Member Function Documentation

◆ GetCurrentFrame()

int VAnimation::GetCurrentFrame ( )
Returns
returns the currently used frame number.

◆ GetFrameCount()

int VAnimation::GetFrameCount ( )
Returns
returns the total amount of frames in the frame list.

◆ Reset()

void VAnimation::Reset ( std::function< void()>  onComplete = nullptr)

Resets the animation to the beginning.

Parameters
onCompleteA callback function used when an animation reaches its end (assuming the animation isn't Looping).

◆ SetCurrentFrame()

void VAnimation::SetCurrentFrame ( int  NewFrame)

Sets the current frame index the animation uses. Do not use this to set the animation's frame number, as this is specified in the frame list.

Parameters
NewFramethe frame index the animation should use. This must be greater than 0 and less than the total amount of frames specified in the frame list.

◆ SetLooping()

void VAnimation::SetLooping ( bool  Looping)
Parameters
LoopingIf true, the animation will now loop, else it won't loop.

◆ SetReverse()

void VAnimation::SetReverse ( bool  Reverse)
Parameters
ReverseIf true, the animation will now play in reverse, else it won't.

◆ Update()

void VAnimation::Update ( float  dt)

Updates the animation, handles changing of frame, callbacks and passing of time.

Parameters
dtDelta Time between the current and previous frame in the game.

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