Nox Engine
 
Loading...
Searching...
No Matches
Animator Struct Reference

Manages sprite sheet animations and transitions between them using a state machine. More...

#include <Animator.h>

Inheritance diagram for Animator:
Inheritance graph
Collaboration diagram for Animator:
Collaboration graph

Classes

struct  Animation
 Represents a single, self-contained animation sequence. More...
 
struct  Edge
 Defines a transition edge between two animations in the state machine. More...
 

Public Member Functions

void init () override
 Initializes the Animator component, acquiring the entity's Sprite component.
 
void update () override
 Updates the current animation state, checking for transitions and advancing the frame.
 
void draw () override
 Draws the current frame of the active animation.
 
void addAnimation (const char *id, const char *texPath, int speed=100, const bool isLooping=true, const bool isReversible=false)
 Adds a new animation state to the animator's state machine.
 
void addEdge (const char *idFrom, const char *idTo, std::vector< std::shared_ptr< bool > > conditions)
 Defines a conditional transition between two animations.
 
std::string getCurrAnimID ()
 Gets the ID of the currently playing animation.
 
- Public Member Functions inherited from Component
virtual void reload ()
 Called to reset the component's state.
 

Additional Inherited Members

- Public Attributes inherited from Component
Entityentity
 Pointer to the entity that owns this component.
 

Detailed Description

Manages sprite sheet animations and transitions between them using a state machine.

This component controls an entity's sprite to play different animation sequences. It uses an adjacency matrix to define transitions (Edges) between animations based on conditions.

Member Function Documentation

◆ addAnimation()

void Animator::addAnimation ( const char id,
const char texPath,
int  speed = 100,
const bool  isLooping = true,
const bool  isReversible = false 
)

Adds a new animation state to the animator's state machine.

Parameters
idThe unique identifier for the new animation.
texPathThe file path to the sprite sheet texture.
speedThe delay in milliseconds between frames.
isLoopingWhether the animation should loop.
isReversibleWhether the animation should play in reverse after finishing.
Here is the call graph for this function:

◆ addEdge()

void Animator::addEdge ( const char idFrom,
const char idTo,
std::vector< std::shared_ptr< bool > >  conditions 
)

Defines a conditional transition between two animations.

Parameters
idFromThe ID of the source animation state.
idToThe ID of the destination animation state.
conditionsA vector of pointers to booleans that must be true to transition.
Here is the call graph for this function:

◆ draw()

void Animator::draw ( )
overridevirtual

Draws the current frame of the active animation.

Reimplemented from Component.

◆ getCurrAnimID()

std::string Animator::getCurrAnimID ( )

Gets the ID of the currently playing animation.

Returns
A string representing the ID of the current animation.

◆ init()

void Animator::init ( )
overridevirtual

Initializes the Animator component, acquiring the entity's Sprite component.

Reimplemented from Component.

Here is the call graph for this function:

◆ update()

void Animator::update ( )
overridevirtual

Updates the current animation state, checking for transitions and advancing the frame.

Reimplemented from Component.

Here is the call graph for this function:

The documentation for this struct was generated from the following files: