|
Aegis2D
Modular C++26 2D game engine for networked games
|
Frames of the entity's Sprite shown in turn, at a steady rate. More...
#include <aegis2d/ecs/components.hpp>
Public Member Functions | |
| constexpr float | duration () const noexcept |
| Length of the clip. | |
| constexpr std::uint32_t | frame () const noexcept |
| Frame to show now. | |
| constexpr bool | finished () const noexcept |
| Tells whether a clip that does not loop has shown its last frame long enough. | |
Public Attributes | |
| std::uint32_t | first = 0 |
| First frame of the clip in the sprite sheet. | |
| std::uint32_t | count = 1 |
| Number of frames of the clip; 0 counts as 1. | |
| float | frame_time = 0.1F |
| Seconds each frame stays on screen; 0 or less keeps the first frame. | |
| bool | loop = true |
true to start again after the last frame, false to stop on it. | |
| float | elapsed = 0.0F |
| Seconds into the clip; kept below duration() while looping. | |
Frames of the entity's Sprite shown in turn, at a steady rate.
The clip is the frames first to first + count - 1 of the texture's sprite sheet (render::SpriteSheet). ecs::animate_sprites() advances elapsed by each tick and sets Sprite::frame to frame(): the frame depends only on the time spent, so the animation runs at the same speed at any tick rate. A looping clip starts again after its last frame; another stays on its last frame, finished(). Starting entities at different elapsed values keeps them from animating in step.
|
inlineconstexprnoexcept |
Length of the clip.
count * frame_time, in seconds.
|
inlineconstexprnoexcept |
Tells whether a clip that does not loop has shown its last frame long enough.
true once elapsed reaches duration() without loop.
|
inlineconstexprnoexcept |
Frame to show now.
first to first + count - 1. | std::uint32_t aegis2d::ecs::Animation::count = 1 |
Number of frames of the clip; 0 counts as 1.
| float aegis2d::ecs::Animation::elapsed = 0.0F |
Seconds into the clip; kept below duration() while looping.
| std::uint32_t aegis2d::ecs::Animation::first = 0 |
First frame of the clip in the sprite sheet.
| float aegis2d::ecs::Animation::frame_time = 0.1F |
Seconds each frame stays on screen; 0 or less keeps the first frame.
| bool aegis2d::ecs::Animation::loop = true |
true to start again after the last frame, false to stop on it.