![]() |
nCine
2025.04.r498-9d36345
A cross-platform 2D game engine
|
A class for an animated sprite. More...
#include <AnimatedSprite.h>
Public Member Functions | |
AnimatedSprite () | |
Default constructor for an animated sprite with no parent and no texture, positioned in the origin. | |
AnimatedSprite (SceneNode *parent, Texture *texture) | |
Constructor for an animated sprite with a parent and texture, positioned in the relative origin. | |
AnimatedSprite (Texture *texture) | |
Constructor for an animated sprite with a texture but no parent, positioned in the origin. | |
AnimatedSprite (SceneNode *parent, Texture *texture, float xx, float yy) | |
Constructor for an animated sprite with a parent, a texture and a specified relative position. | |
AnimatedSprite (SceneNode *parent, Texture *texture, const Vector2f &position) | |
Constructor for an animated sprite with a parent, a texture and a specified relative position as a vector. | |
AnimatedSprite (Texture *texture, float xx, float yy) | |
Constructor for an animated sprite with a texture and a specified position but no parent. | |
AnimatedSprite (Texture *texture, const Vector2f &position) | |
Constructor for an animated sprite with a texture and a specified position as a vector but no parent. | |
AnimatedSprite (AnimatedSprite &&)=default | |
Default move constructor. | |
AnimatedSprite & | operator= (AnimatedSprite &&)=default |
Default move assignment operator. | |
AnimatedSprite | clone () const |
Returns a copy of this object. | |
bool | isPaused () const |
Returns true if the current animation is paused. | |
void | setPaused (bool isPaused) |
Sets the pause state for the animation. | |
void | update (float frameTime) override |
Called once every frame to update the node. More... | |
void | addAnimation (const RectAnimation &anim) |
Adds a new animation. | |
void | addAnimation (RectAnimation &&anim) |
Adds a new animation with move semantics. | |
void | clearAnimations () |
Deletes all animations. | |
unsigned int | numAnimations () |
Returns the number of animations. | |
nctl::Array< RectAnimation > & | animations () |
Returns the array of all animations. | |
const nctl::Array< RectAnimation > & | animations () const |
Returns the constant array of all animations. | |
unsigned int | animationIndex () const |
Returns the current animation index. | |
void | setAnimationIndex (unsigned int animIndex) |
Sets the current animation index. | |
RectAnimation * | currentAnimation () |
Returns the current animation, if any. | |
const RectAnimation * | currentAnimation () const |
Returns the constant version of the current animation, if any. | |
unsigned int | numFrames () const |
Returns the number of frames in current animation. | |
unsigned int | frame () const |
Returns the frame number in current animation. | |
void | setFrame (unsigned int frameNum) |
Sets current animation to a specified frame number. | |
![]() | |
Sprite () | |
Default constructor for a sprite with no parent and no texture, positioned in the origin. | |
Sprite (SceneNode *parent, Texture *texture) | |
Constructor for a sprite with a parent and texture, positioned in the relative origin. | |
Sprite (Texture *texture) | |
Constructor for a sprite with a texture but no parent, positioned in the origin. | |
Sprite (SceneNode *parent, Texture *texture, float xx, float yy) | |
Constructor for a sprite with a parent, a texture and a specified relative position. | |
Sprite (SceneNode *parent, Texture *texture, const Vector2f &position) | |
Constructor for a sprite with a parent, a texture and a specified relative position as a vector. | |
Sprite (Texture *texture, float xx, float yy) | |
Constructor for a sprite with a texture and a specified position but no parent. | |
Sprite (Texture *texture, const Vector2f &position) | |
Constructor for a sprite with a texture and a specified position as a vector but no parent. | |
Sprite (Sprite &&)=default | |
Default move constructor. | |
Sprite & | operator= (Sprite &&)=default |
Default move assignment operator. | |
Sprite | clone () const |
Returns a copy of this object. | |
![]() | |
BaseSprite (BaseSprite &&)=default | |
Default move constructor. | |
BaseSprite & | operator= (BaseSprite &&)=default |
Default move assignment operator. | |
void | setSize (float width, float height) |
Sets the sprite size. | |
void | setSize (const Vector2f &size) |
Sets the sprite size with a Vector2f | |
const Texture * | texture () const |
Gets the texture object. | |
void | setTexture (Texture *texture) |
Sets the texture object. More... | |
void | resetTexture () |
Triggers a texture update without setting a new texture. More... | |
Recti | texRect () const |
Gets the texture source rectangle for blitting. | |
void | setTexRect (const Recti &rect) |
Sets the texture source rectangle for blitting. | |
bool | isFlippedX () const |
Returns true if the sprite texture is horizontally flipped. | |
void | setFlippedX (bool flippedX) |
Flips the texture rect horizontally. | |
bool | isFlippedY () const |
Returns true if the sprite texture is vertically flipped. | |
void | setFlippedY (bool flippedY) |
Flips the texture rect vertically. | |
![]() | |
DrawableNode (SceneNode *parent, float xx, float yy) | |
Constructor for a drawable node with a parent and a specified relative position. | |
DrawableNode (SceneNode *parent, const Vector2f &position) | |
Constructor for a drawable node with a parent and a specified relative position as a vector. | |
DrawableNode (SceneNode *parent) | |
Constructor for a drawable node with a parent and positioned in the relative origin. | |
DrawableNode () | |
Constructor for a drawable node with no parent and positioned in the origin. | |
DrawableNode (DrawableNode &&) | |
Default move constructor. | |
DrawableNode & | operator= (DrawableNode &&) |
Default move assignment operator. | |
bool | draw (RenderQueue &renderQueue) override |
Updates the draw command and adds it to the queue. | |
virtual float | width () const |
Returns the width of the node area. | |
virtual float | height () const |
Returns the height of the node area. | |
Vector2f | size () const |
Returns the size of the node area. | |
virtual float | absWidth () const |
Returns the absolute width of the node area. | |
virtual float | absHeight () const |
Returns the absolute height of the node area. | |
Vector2f | absSize () const |
Returns the absolute size of the node area. | |
Vector2f | anchorPoint () const |
Gets the transformation anchor point. | |
void | setAnchorPoint (float xx, float yy) |
Sets the transformation anchor point. More... | |
void | setAnchorPoint (const Vector2f &point) |
Sets the transformation anchor point with a Vector2f | |
bool | isBlendingEnabled () const |
Returns true if the node renders with blending enabled. | |
void | setBlendingEnabled (bool blendingEnabled) |
Sets the blending state for node rendering. | |
BlendingFactor | srcBlendingFactor () const |
Returns the source blending factor. | |
BlendingFactor | destBlendingFactor () const |
Returns the destination blending factor. | |
void | setBlendingPreset (BlendingPreset blendingPreset) |
Sets a blending preset for source and destination blending factors. | |
void | setBlendingFactors (BlendingFactor srcBlendingFactor, BlendingFactor destBlendingFactor) |
Sets a specific source and destination blending factors. | |
unsigned long int | lastFrameRendered () const |
Returns the last frame in which any of the viewports have rendered this node (node was not culled) | |
Rectf | aabb () const |
Returns the axis-aligned bounding box of the node area in the last frame. | |
![]() | |
SceneNode (SceneNode *parent, float x, float y) | |
Constructor for a node with a parent and a specified relative position. More... | |
SceneNode (SceneNode *parent, const Vector2f &position) | |
Constructor for a node with a parent and a specified relative position as a vector. More... | |
SceneNode (SceneNode *parent) | |
Constructor for a node with a parent and positioned in the relative origin. More... | |
SceneNode () | |
Constructor for a node with no parent and positioned in the origin. | |
~SceneNode () override | |
The destructor will delete every child node. | |
SceneNode (SceneNode &&other) | |
Move constructor. | |
SceneNode & | operator= (SceneNode &&other) |
Move assignment operator. | |
SceneNode | clone () const |
Returns a copy of this object. | |
const SceneNode * | parent () const |
Returns the parent as a constant node, if there is any. | |
SceneNode * | parent () |
Returns the parent node, if there is any. | |
bool | setParent (SceneNode *parentNode) |
Sets the parent node. More... | |
const nctl::Array< SceneNode * > & | children () |
Returns the array of child nodes. | |
const nctl::Array< const SceneNode * > & | children () const |
Returns an array of constant child nodes. | |
bool | addChildNode (SceneNode *childNode) |
Adds a node as a child of this one. More... | |
bool | removeChildNode (SceneNode *childNode) |
Removes a child of this node, without reparenting nephews. More... | |
bool | removeChildNodeAt (unsigned int index) |
Removes the child at the specified index, without reparenting nephews. More... | |
bool | removeAllChildrenNodes () |
Removes all children, without reparenting nephews. More... | |
bool | unlinkChildNode (SceneNode *childNode) |
Removes a child of this node reparenting nephews as children. More... | |
unsigned int | childOrderIndex () const |
Returns the child order index of this node or zero if it does not have a parent. More... | |
bool | swapChildrenNodes (unsigned int firstIndex, unsigned int secondIndex) |
Swaps two children at the specified indices. More... | |
bool | swapNodeForward () |
Brings this node one node forward in the parent's list of children. More... | |
bool | swapNodeBack () |
Brings this node one node back in the parent's list of children. More... | |
enum VisitOrderState | visitOrderState () const |
Returns true if the node visit order is used together with the layer. | |
void | setVisitOrderState (enum VisitOrderState visitOrderState) |
Enables the use of the node visit order together with the layer. | |
uint16_t | visitOrderIndex () const |
Returns the visit drawing order of the node. | |
virtual void | visit (RenderQueue &renderQueue, unsigned int &visitOrderIndex) |
Draws the node and visits its children. | |
bool | isUpdateEnabled () const |
Returns true if the node is updating. | |
void | setUpdateEnabled (bool updateEnabled) |
Enables or disables node updating. | |
bool | isDrawEnabled () const |
Returns true if the node is drawing. | |
void | setDrawEnabled (bool drawEnabled) |
Enables or disables node drawing. | |
bool | isEnabled () const |
Returns true if the node is both updating and drawing. | |
void | setEnabled (bool isEnabled) |
Enables or disables both node updating and drawing. | |
Vector2f | position () const |
Returns node position relative to its parent. | |
Vector2f | absPosition () const |
Returns absolute node position. | |
void | setPosition (float x, float y) |
Sets the node position through two coordinates. | |
void | setPosition (const Vector2f &position) |
Sets the node position through a vector. | |
void | setPositionX (float x) |
Sets the X coordinate of the node position. | |
void | setPositionY (float y) |
Sets the Y coordinate of the node position. | |
void | move (float x, float y) |
Moves the node based on two offsets. | |
void | move (const Vector2f &position) |
Adds a move vector to the node current position. | |
void | moveX (float x) |
Moves the node by an offset on the X axis. | |
void | moveY (float y) |
Moves the node by an offset on the Y axis. | |
Vector2f | absAnchorPoint () const |
Gets the absolute transformation anchor point in pixels. | |
void | setAbsAnchorPoint (float x, float y) |
Sets the absolute transformation anchor point in pixels. | |
void | setAbsAnchorPoint (const Vector2f &point) |
Sets the absolute transformation anchor point in pixels with a Vector2f | |
const Vector2f & | scale () const |
Gets the node scale factors. | |
const Vector2f & | absScale () const |
Gets the node absolute scale factors. | |
void | setScale (float scaleFactor) |
Scales the node size both horizontally and vertically. | |
void | setScale (float scaleFactorX, float scaleFactorY) |
Scales the node size both horizontally and vertically. | |
void | setScale (const Vector2f &scaleFactor) |
Scales the node size both horizontally and vertically with a Vector2f | |
float | rotation () const |
Gets the node rotation in degrees. | |
float | absRotation () const |
Gets the node absolute rotation in degrees. | |
void | setRotation (float rotation) |
Sets the node rotation in degrees. | |
Color | color () const |
Gets the node color. | |
Color | absColor () const |
Gets the node absolute color. | |
void | setColor (Color color) |
Sets the node color through a Color object. | |
void | setColorF (Colorf color) |
Sets the node color through a Colorf object. | |
void | setColor (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) |
Sets the node color through unsigned char components. | |
void | setColorF (float red, float green, float blue, float alpha) |
Sets the node color through float components. | |
unsigned char | alpha () const |
Gets the node alpha. | |
unsigned char | absAlpha () const |
Gets the node absolute alpha. | |
void | setAlpha (unsigned char alpha) |
Sets the node alpha through an unsigned char component. | |
void | setAlphaF (float alpha) |
Sets the node alpha through a float component. | |
uint16_t | layer () const |
Gets the node rendering layer. | |
uint16_t | absLayer () const |
Gets the node absolute rendering layer. More... | |
void | setLayer (uint16_t layer) |
Sets the node rendering layer. More... | |
const Matrix4x4f & | worldMatrix () const |
Gets the node world matrix. | |
void | setWorldMatrix (const Matrix4x4f &worldMatrix) |
Sets the node world matrix (only useful when called inside onPostUpdate() ) | |
const Matrix4x4f & | localMatrix () const |
Gets the node local matrix. | |
void | setLocalMatrix (const Matrix4x4f &localMatrix) |
Sets the node local matrix. | |
bool | deleteChildrenOnDestruction () const |
Gets the delete children on destruction flag. More... | |
void | setDeleteChildrenOnDestruction (bool shouldDeleteChildrenOnDestruction) |
Sets the delete children on destruction flag. | |
unsigned long int | lastFrameUpdated () const |
Returns the last frame in which any of the viewports have updated this node. | |
![]() | |
Object (ObjectType type) | |
Constructs an object with a specified type and adds it to the index. | |
Object (ObjectType type, const char *name) | |
Constructs an object with a specified type and name and adds it to the index. | |
virtual | ~Object () |
Removes an object from the index and then destroys it. | |
Object (Object &&other) | |
Move constructor. | |
Object & | operator= (Object &&other) |
Move assignment operator. | |
unsigned int | id () const |
Returns the object identification number. | |
ObjectType | type () const |
Returns the object type (RTTI) | |
const char * | name () const |
Returns the object name. | |
void | setName (const char *name) |
Sets the object name. | |
Static Public Member Functions | |
static ObjectType | sType () |
![]() | |
static ObjectType | sType () |
![]() | |
static ObjectType | sType () |
![]() | |
static ObjectType | sType () |
Static method to return class type. | |
template<class T > | |
static T * | fromId (unsigned int id) |
Returns a casted pointer to the object with the specified id, if any exists. | |
Protected Member Functions | |
AnimatedSprite (const AnimatedSprite &other) | |
Protected copy constructor used to clone objects. | |
![]() | |
Sprite (const Sprite &other) | |
Protected copy constructor used to clone objects. | |
![]() | |
BaseSprite (SceneNode *parent, Texture *texture, float xx, float yy) | |
Protected constructor accessible only by derived sprite classes. | |
BaseSprite (SceneNode *parent, Texture *texture, const Vector2f &position) | |
Protected constructor accessible only by derived sprite classes. | |
BaseSprite (const BaseSprite &other) | |
Protected copy constructor used to clone objects. | |
void | shaderHasChanged () override |
Performs the required tasks upon a change to the shader. | |
void | updateRenderCommand () override |
Updates the render command. | |
![]() | |
virtual void | updateAabb () |
Calculates updated values for the AABB. | |
void | updateCulling () |
Called by each viewport update method to update a node culling state. | |
DrawableNode (const DrawableNode &other) | |
Protected copy constructor used to clone objects. | |
![]() | |
SceneNode & | operator= (const SceneNode &)=delete |
Deleted assignment operator. | |
SceneNode (const SceneNode &other) | |
Protected copy constructor used to clone objects. | |
void | swapChildPointer (SceneNode *first, SceneNode *second) |
Swaps the child pointer of a parent when moving an object. More... | |
virtual void | transform () |
![]() | |
Object (const Object &other) | |
Protected copy constructor used to clone objects. | |
Additional Inherited Members | |
![]() | |
enum class | BlendingPreset { DISABLED , ALPHA , PREMULTIPLIED_ALPHA , ADDITIVE , MULTIPLY } |
Presets for blending factors. More... | |
enum class | BlendingFactor { ZERO , ONE , SRC_COLOR , ONE_MINUS_SRC_COLOR , DST_COLOR , ONE_MINUS_DST_COLOR , SRC_ALPHA , ONE_MINUS_SRC_ALPHA , DST_ALPHA , ONE_MINUS_DST_ALPHA , CONSTANT_COLOR , ONE_MINUS_CONSTANT_COLOR , CONSTANT_ALPHA , ONE_MINUS_CONSTANT_ALPHA , SRC_ALPHA_SATURATE } |
OpenGL blending factors. | |
![]() | |
enum class | VisitOrderState { ENABLED , DISABLED , SAME_AS_PARENT } |
![]() | |
enum class | ObjectType { BASE = 0 , TEXTURE , SHADER , SCENENODE , SPRITE , MESH_SPRITE , ANIMATED_SPRITE , PARTICLE , PARTICLE_SYSTEM , FONT , TEXTNODE , AUDIOBUFFER , AUDIOBUFFER_PLAYER , AUDIOSTREAM_PLAYER } |
Object types. | |
![]() | |
static const Vector2f | AnchorCenter |
static const Vector2f | AnchorBottomLeft |
static const Vector2f | AnchorTopLeft |
static const Vector2f | AnchorBottomRight |
static const Vector2f | AnchorTopRight |
![]() | |
static const float | MinRotation = 0.5f |
The minimum amount of rotation to trigger a sine and cosine calculation. | |
![]() | |
static const unsigned int | MaxNameLength = 128 |
Maximum length for an object name. | |
![]() | |
enum | DirtyBitPositions { TransformationBit = 0 , ColorBit = 1 , SizeBit = 2 , TextureBit = 3 , AabbBit = 4 , TransformationUploadBit = 5 , ColorUploadBit = 6 } |
Bit positions inside the dirty bitset. | |
![]() | |
Texture * | texture_ |
The sprite texture. | |
Recti | texRect_ |
The texture source rectangle. | |
bool | flippedX_ |
A flag indicating if the sprite texture is horizontally flipped. | |
bool | flippedY_ |
A flag indicating if the sprite texture is vertically flipped. | |
GLUniformBlockCache * | instanceBlock_ |
![]() | |
float | width_ |
Node width in pixel. | |
float | height_ |
Node height in pixel. | |
nctl::UniquePtr< RenderCommand > | renderCommand_ |
The render command class associated with this node. | |
unsigned long int | lastFrameRendered_ |
The last frame any viewports rendered this node. | |
Rectf | aabb_ |
Axis-aligned bounding box of the node area. | |
![]() | |
bool | updateEnabled_ |
bool | drawEnabled_ |
SceneNode * | parent_ |
A pointer to the parent node. | |
nctl::Array< SceneNode * > | children_ |
The array of child nodes. | |
unsigned int | childOrderIndex_ |
The order index of this node among its siblings. More... | |
bool | withVisitOrder_ |
When enabled the visit order is used to resolve the drawing order of same layer nodes. More... | |
enum VisitOrderState | visitOrderState_ |
The visit order state of this node. | |
uint16_t | visitOrderIndex_ |
The visit order index of this node. | |
Vector2f | position_ |
The node relative position. | |
Vector2f | anchorPoint_ |
Vector2f | scaleFactor_ |
Horizontal and vertical scale factors for node size. | |
float | rotation_ |
Degrees for clock-wise node rotation in degrees. | |
Color | color_ |
Node color for transparency and translucency. More... | |
uint16_t | layer_ |
The node rendering layer. More... | |
Vector2f | absPosition_ |
Absolute position as calculated by the transform() function. | |
Vector2f | absScaleFactor_ |
Absolute horizontal and vertical scale factors as calculated by the transform() function. | |
float | absRotation_ |
Absolute node rotation as calculated by the transform() function. | |
Color | absColor_ |
Absolute node color as calculated by the transform() function. | |
uint16_t | absLayer_ |
Absolute node rendering layer as calculated by the transform() function. | |
Matrix4x4f | worldMatrix_ |
World transformation matrix (calculated from local and parent's world) | |
Matrix4x4f | localMatrix_ |
Local transformation matrix. | |
bool | shouldDeleteChildrenOnDestruction_ |
A flag indicating whether the destructor should also delete all children. | |
nctl::BitSet< uint8_t > | dirtyBits_ |
Bitset that stores the various dirty states bits. | |
unsigned long int | lastFrameUpdated_ |
The last frame any viewport updated this node. | |
![]() | |
ObjectType | type_ |
Object type. | |
A class for an animated sprite.
|
overridevirtual |
Called once every frame to update the node.
Reimplemented from ncine::SceneNode.