anim::Animation
Animation class should be used to create an animation in sfml. More...
#include <Animation.hpp>
Public Functions
~Animation() =default Destroy the instance of Animation. It's set to default.
void
update() It updates the texture used depending on the duration time and the previous index in the vector of texture.
void
addTexture(const std::string & texturePath, const sf::Vector2f & position, const sf::Vector2f & size) It adds a texture on the vector of texture used for the animation.
void
addTexture(const sf::Image & image, const sf::Vector2f & position, const sf::Vector2f & size) It adds a texture on the vector of texture used for the animation.
const sf::RectangleShape &
getShape() const It returns the shape of the animation with the correct texture.
void
moveShape(const sf::Vector2f & move) It move the shape of the animation with the vector2f move.
void
setDuration(const std::size_t & duration) It sets the duration between each frame of the animation.
const std::size_t &
getDuration() const It gets the duration between each frame of the animation.
void
setPosition(const sf::Vector2f & position) It sets the position of the shape used for the animation.
const sf::Vector2f &
getPosition() const It gets the position of the shape used for the animation.
void
setSize(const sf::Vector2f & size) It sets the size of the shape used for the animation.
const sf::Vector2f &
getSize() const It gets the size of the shape used for the animation.
const sf::FloatRect
getGlobalBounds() It gets the size of the shape used for the animation.
void
setColor(const sf::Color & color) It sets the color of the shape used for the animation.
const sf::Color &
getColor() const It gets the color of the shape used for the animation.
Detailed Description
Animation class should be used to create an animation in sfml.
Note: It contains a vector of texture that will be updated, depending on a duration time, with the function update. You should define a duration between each frame. You should define a position for the animation. You should define a size for the animation. You should add a texture for the animation.
Warning: A texture is always add at the end of the vector of texture.
Public Functions Documentation
function Animation
Create a new instance of Animation.
function ~Animation
Destroy the instance of Animation. It's set to default.
function update
It updates the texture used depending on the duration time and the previous index in the vector of texture.
function addTexture
It adds a texture on the vector of texture used for the animation.
Parameters:
texturePath The path to load the texture from.
position The position from which the texture of the loaded image is to be obtained.
size The size to get the texture from in the image loaded.
Exceptions:
AnimationException will be thrown if the image cannot be loaded.
Warning: Be carful, the texture is added at the end of the vector. Please add texture in the correct order.
function addTexture
It adds a texture on the vector of texture used for the animation.
Parameters:
image The image used to create the texture from.
position The position from which the texture of the loaded image is to be obtained.
size The size to get the texture from in the image loaded.
Exceptions:
AnimationException will be thrown if the texture cannot be created.
Warning: Be carful, the texture is added at the end of the vector. Please add texture in the correct order.
function getShape
It returns the shape of the animation with the correct texture.
Return: const sf::RectangleShape reference of the shape.
Note: Use this function to get the shape to be drawn.
Warning: Keep in mind that you need to update the texture with the update function.
function moveShape
It move the shape of the animation with the vector2f move.
Note: Use this function to move the shape.
Warning: Keep in mind that you need to draw the shape again.
function setDuration
It sets the duration between each frame of the animation.
Parameters:
duration The duration between each frame of the animation as millisecond.
Note: The animation must be set as millisecond.
function getDuration
It gets the duration between each frame of the animation.
Return: const std::size_t reference of the duration.
function setPosition
It sets the position of the shape used for the animation.
Parameters:
position The position to be set on the shape.
function getPosition
It gets the position of the shape used for the animation.
Return: const sf::Vector2f reference of the position.
function setSize
It sets the size of the shape used for the animation.
Parameters:
size The size to be set on the shape.
function getSize
It gets the size of the shape used for the animation.
Return: const sf::Vector2f reference of the size.
function getGlobalBounds
It gets the size of the shape used for the animation.
Return: const sf::Vector2f reference of the size.
function setColor
It sets the color of the shape used for the animation.
Parameters:
color The color to be set on the shape.
function getColor
It gets the color of the shape used for the animation.
Return: const sf::Color reference of the size.
Updated on 2022-11-13 at 17:21:37 +0100
Last updated