nCine::RectAnimation class

Sequence of texture rectangles forming a sprite animation.

Stores an ordered list of source rectangles and their per-frame durations, advancing the current frame over time according to the configured LoopMode. A sprite samples the rect() of its animation each frame to display the matching region of its texture.

Public types

enum class LoopMode { NoRepeat, FromStart, Backward }
Animation loop modes.

Constructors, destructors, conversion operators

RectAnimation()
Default constructor.
RectAnimation(float defaultFrameDuration, LoopMode loopMode)
Constructs an animation with the specified default frame duration and loop mode.

Public functions

auto isPaused() const -> bool
Returns whether the animation is paused.
void setPaused(bool isPaused)
Sets the pause flag.
void updateFrame(float interval)
Advances the current frame by the time elapsed since the last update.
auto frame() const -> std::uint32_t
Returns the current frame index.
void setFrame(std::uint32_t frameNum)
Sets the current frame index.
auto defaultFrameDuration() const -> float
Returns the default frame duration in seconds.
void setDefaultFrameDuration(float defaultFrameDuration)
Sets the default frame duration in seconds.
auto loopMode() const -> LoopMode
Returns the loop mode.
void setLoopMode(LoopMode loopMode)
Sets the loop mode.
void addRect(const Recti& rect, float frameTime)
Appends a rectangle with the specified frame duration.
void addRect(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h, float frameTime)
Creates a rectangle from origin and size and appends it with the specified frame duration.
void addRect(const Recti& rect)
Appends a rectangle with the default frame duration.
void addRect(std::int32_t x, std::int32_t y, std::int32_t w, std::int32_t h)
Creates a rectangle from origin and size and appends it with the default frame duration.
auto rect() const -> const Recti&
Returns the current rectangle.
auto frameDuration() const -> float
Returns the current frame duration in seconds.
auto rectangles() -> SmallVectorImpl<Recti>&
Returns the array of all rectangles.
auto rectangles() const -> const SmallVectorImpl<Recti>&
Returns the array of all rectangles (read-only).
auto frameDurations() -> SmallVectorImpl<float>&
Returns the array of all frame durations.
auto frameDurations() const -> const SmallVectorImpl<float>&
Returns the array of all frame durations (read-only).

Enum documentation

enum class nCine::RectAnimation::LoopMode

Animation loop modes.

Enumerators
NoRepeat

When the animation reaches the last frame it stops and pauses

FromStart

When the animation reaches the last frame it begins again from start

Backward

When the animation reaches the last frame it plays in reverse, ping-ponging