Animations¶
-
namespace
tnt
-
namespace
doo
¶ Variables
-
struct tnt::doo::animations_sys
animations
¶
-
struct
animation_comp
¶ - #include <Animations.hpp>
A struct that holds the data for an animation.
Public Types
Public Functions
-
constexpr
animation_comp
(Rectangle const &rect, int const framesCount, float const animSpeed, float const space, direction const &dir_, wrap_mode const &wrap_) noexcept¶ Create a new animation component.
- Parameters
rect
: The size of a frame on the image.framesCount
: The number of frames that the animation has.animSpeed
: The speed the animation should be played with.space
: The spacing between the frames of the sprites, 0.f if none.dir_
: The direction of the frames on the image.wrap_
: The wrap mode of the animation.
-
constexpr
-
struct
animations_sys
¶ - #include <Animations.hpp>
The system that controls the animations of the sprites.
Public Functions
-
void
add_object
(object const &id, animation_comp const &anim_)¶ Add an object to the animations system.
- Parameters
id
: The id of the object to add to the animations system.anim_
: The data of the animation.
-
void
Update
(object const &id, float time_) noexcept¶ Update the animation of the given object.
- Parameters
id
: The id of the object’s animation to update.time_
: The time elapsed since the last Update() call.
-
void
from_json
(object const &id, nlohmann::json const &j)¶ Load animation data from a json chunk.
- Parameters
id
: The id of the object to load from json.j
: The json chunk.
-
void
to_json
(object const &id, nlohmann::json &j)¶ Store animation data of a specific object to a json chunk.
- Parameters
id
: The id of the object to serialize to json.j
: The json chunk where the data will be saved.
-
void
remove
(object const &id) noexcept¶ Remove the desired object from the animations system.
- Parameters
id
: The id of the object you want to remove.
-
void
clear
() noexcept¶ Remove all the entities from the animations system.
Public Members
-
std::vector<animation_comp::wrap_mode>
wrap
¶
-
std::vector<animation_comp::direction>
dir
¶ < The wrap modes of the animations.
-
std::vector<float>
startX
¶ < The direction of the frames on the image.
-
std::vector<float>
startY
¶ < The starting x coordinate of the animation.
-
std::vector<float>
speed
¶ < The starting y coordinate of the animation.
-
std::vector<float>
elapsed
¶ < The speed of the animation.
-
std::vector<float>
timePerFrame
¶ < The elapsed time since the beginning of the animation.
-
std::vector<float>
spacing
¶ < Shows how long a frame should be drawed.
-
std::vector<int>
current
¶ < The spacing between the frames of the sprites, 0 if none.
-
void
-
struct tnt::doo::animations_sys
-
namespace