AnimatedSprite class
#include <nCine/Graphics/AnimatedSprite.h>
Textured sprite that cycles through one or more frame animations.
Extends Sprite with a set of RectAnimation instances. The active animation advances its texture rectangle over time during OnUpdate, allowing several named animations to be stored and switched between by index.
Base classes
- class Sprite
- Scene node that draws a single textured quad.
Public static functions
- static auto sType() -> ObjectType
Constructors, destructors, conversion operators
- AnimatedSprite()
- Creates a sprite with no parent and no texture, positioned at the origin.
- AnimatedSprite(SceneNode* parent, Texture* texture)
- Creates a sprite as a child of
parent, positioned at the relative origin. - AnimatedSprite(Texture* texture) explicit
- Creates a sprite with a texture but no parent, positioned at the origin.
- AnimatedSprite(SceneNode* parent, Texture* texture, float xx, float yy)
- Creates a sprite as a child of
parentat the relative position (xx,yy). - AnimatedSprite(SceneNode* parent, Texture* texture, Vector2f position)
- Creates a sprite as a child of
parentat the relative positionposition. - AnimatedSprite(Texture* texture, float xx, float yy)
- Creates a sprite with a texture but no parent at the position (
xx,yy). - AnimatedSprite(Texture* texture, Vector2f position)
- Creates a sprite with a texture but no parent at the position
position. - AnimatedSprite(AnimatedSprite&&) defaulted
- AnimatedSprite(const AnimatedSprite& other) protected
- Protected copy constructor used to clone objects.
Public functions
- auto operator=(const AnimatedSprite&) -> AnimatedSprite& deleted
- auto operator=(AnimatedSprite&&) -> AnimatedSprite& defaulted
- auto clone() const -> AnimatedSprite
- Returns a copy of this object.
- auto isPaused() const -> bool
- Returns whether the current animation is paused.
- void setPaused(bool isPaused)
- Sets the pause state of the current animation.
- void OnUpdate(float timeMult) override
- Called every frame to update the node state.
- void addAnimation(const RectAnimation& anim)
- Adds a new animation.
- void addAnimation(RectAnimation&& anim)
- Adds a new animation with move semantics.
- void clearAnimations()
- Removes all animations.
-
auto numAnimations() -> std::
uint32_t - Returns the number of animations.
- auto animations() -> SmallVectorImpl<RectAnimation>&
- Returns the array of all animations.
- auto animations() const -> const SmallVectorImpl<RectAnimation>&
- Returns the array of all animations (read-only).
-
auto animationIndex() const -> std::
uint32_t - Returns the index of the current animation.
-
void setAnimationIndex(std::
uint32_t animIndex) - Sets the current animation by index and resets its frame number.
- auto currentAnimation() -> RectAnimation*
- Returns the current animation, or
nullptrif there is none. - auto currentAnimation() const -> const RectAnimation*
- Returns the current animation (read-only), or
nullptrif there is none. -
auto frame() const -> std::
uint32_t - Returns the frame number of the current animation.
-
void setFrame(std::
uint32_t frameNum) - Sets the current animation to the specified frame number.