Handles storing and switching between multiple VAnimations.
More...
#include <VAnimationManager.h>
|
| VAnimationManager (int TextureWidth, int TextureHeight, int FrameWidth, int FrameHeight, int OffsetX, int OffsetY) |
|
sf::IntRect | GetTextureArea () |
|
void | AddAnimation (const sf::String &name, const std::vector< int > &Frames, float FramesPerSecond=6.0f, bool Looping=false, bool Reverse=false) |
|
void | AddAnimation (const sf::String &name, int Begin, int Length, float FramesPerSecond=6.0f, bool Looping=false, bool Reverse=false) |
|
const sf::String & | CurrentAnimationName () |
|
void | Play (const sf::String &name, std::function< void()> onComplete=nullptr) |
|
void | SetPaused (bool value) |
|
void | Stop () |
| Stop all animations.
|
|
void | Reset (std::function< void()> onComplete=nullptr) |
|
void | Reset (const sf::String &name, std::function< void()> onComplete=nullptr) |
|
void | Update (float dt) |
|
void | SetCurrentFrame (int NewFrame) |
|
int | GetCurrentFrame () |
|
int | GetLastFrame () |
|
void | SetLooping (bool Looping) |
|
void | SetReverse (bool Reverse) |
|
int | GetU () |
|
int | GetV () |
|
void | Clear () |
| Clears entire animation list.
|
|
int | Count () |
|
Handles storing and switching between multiple VAnimations.
◆ VAnimationManager()
VAnimationManager::VAnimationManager |
( |
int |
TextureWidth, |
|
|
int |
TextureHeight, |
|
|
int |
FrameWidth, |
|
|
int |
FrameHeight, |
|
|
int |
OffsetX, |
|
|
int |
OffsetY |
|
) |
| |
- Parameters
-
TextureWidth | The width of the texture in pixels being used, or the partial width if the entire texture won't be used. |
TextureHeight | The height of the texture in pixels being used, or the partial height if the entire texture won't be used. |
FrameWidth | The width of a single frame in pixels. |
FrameHeight | The height of a single frame in pixels. |
OffsetX | The offset of the X axis in pixels, imporant if the area of animation is not the entire texture. |
OffsetY | The offset of the Y axis in pixels, imporant if the area of animation is not the entire texture. |
◆ AddAnimation() [1/2]
void VAnimationManager::AddAnimation |
( |
const sf::String & |
name, |
|
|
const std::vector< int > & |
Frames, |
|
|
float |
FramesPerSecond = 6.0f , |
|
|
bool |
Looping = false , |
|
|
bool |
Reverse = false |
|
) |
| |
Adds a new animation to the manager. If an animation under the name already exists, then a new VAnimation will replace it.
- Parameters
-
name | Name of animation, used for the ID in the animation list. |
Frames | Frames The 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 }). |
FramesPerSecond | The amount of frames to play per second in time. This gets converted to a frameDelay using 1 / FramesPerSecond. Must be greater than 0. |
Looping | Whether the animation should loop or not. |
Reverse | Whether the animation should reverse or not. |
◆ AddAnimation() [2/2]
void VAnimationManager::AddAnimation |
( |
const sf::String & |
name, |
|
|
int |
Begin, |
|
|
int |
Length, |
|
|
float |
FramesPerSecond = 6.0f , |
|
|
bool |
Looping = false , |
|
|
bool |
Reverse = false |
|
) |
| |
Adds a new animation to the manager. If an animation under the name already exists, then a new VAnimation will replace it. Unlike the other method, this one allows will set up a list of frames is of a range of numbers, to save passing in a std::vector<int>.
- Parameters
-
name | Name of animation, used for the ID in the animation list. |
Begin | The beginning frame number of the animation. |
Length | The total amount of frames this animation will have. (e.g. if Begin is 0 and Length is 5, the frame list created will be { 0, 1, 2, 3, 4 }) |
FramesPerSecond | The amount of frames to play per second in time. This gets converted to a frameDelay using 1 / FramesPerSecond. Must be greater than 0. |
Looping | Whether the animation should loop or not. |
Reverse | Whether the animation should reverse or not. |
◆ Count()
int VAnimationManager::Count |
( |
| ) |
|
- Returns
- Returns the amount of animations being stored in the animation manager.
◆ CurrentAnimationName()
const sf::String& VAnimationManager::CurrentAnimationName |
( |
| ) |
|
- Returns
- returns the String name/id of the currently playing animation.
◆ GetCurrentFrame()
int VAnimationManager::GetCurrentFrame |
( |
| ) |
|
- Returns
- The currently used frame number, regardless of whether an animation is currently being used or not.
◆ GetLastFrame()
int VAnimationManager::GetLastFrame |
( |
| ) |
|
- Returns
- The previous frame used in the last game's loop.
◆ GetTextureArea()
sf::IntRect VAnimationManager::GetTextureArea |
( |
| ) |
|
- Returns
- An sf::IntRect of the entire area of the texture where the animation is used.
◆ GetU()
int VAnimationManager::GetU |
( |
| ) |
|
- Returns
- Returns the current U/X coordinate of the texture for rendering purposes.
◆ GetV()
int VAnimationManager::GetV |
( |
| ) |
|
- Returns
- Returns the current V/Y coordinate of the texture for rendering purposes.
◆ Play()
void VAnimationManager::Play |
( |
const sf::String & |
name, |
|
|
std::function< void()> |
onComplete = nullptr |
|
) |
| |
Plays an animation. If the animation specified is already being played then nothing will happen. If you wish to replay the current animation, use the Reset function.
- Parameters
-
name | The name/id of the animation you wish to play. Must be an animation previously added to the scene. |
onComplete | A callback function, used when the animation is completed. |
◆ Reset() [1/2]
void VAnimationManager::Reset |
( |
std::function< void()> |
onComplete = nullptr | ) |
|
Resets the current animation being played.
- Parameters
-
onComplete | A callback function, used when the animation is completed. |
◆ Reset() [2/2]
void VAnimationManager::Reset |
( |
const sf::String & |
name, |
|
|
std::function< void()> |
onComplete = nullptr |
|
) |
| |
Resets one of the animations in the manager.
- Parameters
-
name | The name/id of the animation to use. |
onComplete | A callback function, used when the animation is completed. |
◆ SetCurrentFrame()
void VAnimationManager::SetCurrentFrame |
( |
int |
NewFrame | ) |
|
Sets the current frame index the current animation. Do not use this to set the current animation's frame number, as this is specified in the current animation's frame list. The only exception is if no current animation has been set, then the frame number can be passed in.
- Parameters
-
NewFrame | The frame index the current animation should use. This must be greater than 0 and less than the total amount of frames specified in the current animation's frame list. |
◆ SetLooping()
void VAnimationManager::SetLooping |
( |
bool |
Looping | ) |
|
- Parameters
-
Looping | If true, the current animation will now loop, else it won't loop. |
◆ SetPaused()
void VAnimationManager::SetPaused |
( |
bool |
value | ) |
|
- Parameters
-
value | True pauses the current animation, False resumes the current animation. |
◆ SetReverse()
void VAnimationManager::SetReverse |
( |
bool |
Reverse | ) |
|
- Parameters
-
Reverse | If true, the current animation will now play in reverse, else it won't. |
◆ Update()
void VAnimationManager::Update |
( |
float |
dt | ) |
|
Updates the current animation, assuming pause isn't set to true.
- Parameters
-
dt | Delta Time between the current and previous frame in the game. |
The documentation for this class was generated from the following file: