Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
Animator Class Reference

Component that handles sprite sheet animations. More...

#include <animator.h>

Inheritance diagram for Animator:
[legend]

Public Member Functions

 Animator (const std::string &sprite_sheet_name, int interval_ms)
 
void play (bool is_looping)
 
void play (const std::string &animation_name, bool is_looping)
 
void pause ()
 
void reset ()
 
bool is_playing () const noexcept
 
bool is_non_interruptible () const noexcept
 
void is_non_interruptible (bool value) noexcept
 
void update (float dt_seconds) override
 
void set_animation (const std::string &animation_name)
 
void set_animation (const std::vector< std::reference_wrapper< Texture > > &frames_)
 
std::string type_name () const override
 Provides a consistent type name for the component.
 
- Public Member Functions inherited from Component
 Component ()
 
virtual ~Component ()=default
 
bool active () const noexcept
 Checks if the component is active.
 
Componentactive (bool value) noexcept
 
bool marked_for_deletion () const noexcept
 Activates the component.
 
Componentmark_for_deletion () noexcept
 
virtual void on_attach ()
 Called when the component is attached to a GameObject.
 
virtual void on_detach ()
 Called when the component is detached from a GameObject.
 
virtual void on_serialize (std::vector< uint8_t > &) const
 Serializes the component's state into a byte array.
 
virtual void on_deserialize (const std::vector< uint8_t > &, size_t &)
 Deserializes the component's state from a byte array.
 
const std::optional< std::reference_wrapper< GameObject > > & parent () const noexcept
 Gets the parent GameObject of this component.
 
std::optional< std::reference_wrapper< GameObject > > & parent () noexcept
 Gets the parent GameObject of this component.
 
Componentparent (GameObject &parent)
 
Componentparent (std::nullopt_t nullopt)
 
size_t add_on_attach (const std::function< void(Component &)> &action)
 Retrieves the type information of the component.
 
void remove_on_attach (size_t index)
 
size_t add_on_detach (const std::function< void(Component &)> &action)
 Adds an action to be performed when the component is attached.
 
void remove_on_detach (size_t index)
 

Detailed Description

Component that handles sprite sheet animations.

The Animator component allows you to create frame-by-frame animations using a sprite sheet. You can control playback, looping, and frame timing.

Usage:

  • Create an Animator with a sprite sheet and frame interval.
  • Use play(), pause(), and reset() to control animation playback.
  • Set specific animations using set_animation().
  • The component updates the sprite texture based on the current frame.
    Note
    Ensure the parent GameObject has a Sprite component to display frames.

Constructor & Destructor Documentation

◆ Animator()

Animator::Animator ( const std::string &  sprite_sheet_name,
int  interval_ms 
)
explicit

Member Function Documentation

◆ is_non_interruptible() [1/2]

bool Animator::is_non_interruptible ( ) const
noexcept

◆ is_non_interruptible() [2/2]

void Animator::is_non_interruptible ( bool  value)
noexcept

◆ is_playing()

bool Animator::is_playing ( ) const
noexcept

◆ pause()

void Animator::pause ( )

◆ play() [1/2]

void Animator::play ( bool  is_looping)

◆ play() [2/2]

void Animator::play ( const std::string &  animation_name,
bool  is_looping 
)

◆ reset()

void Animator::reset ( )

◆ set_animation() [1/2]

void Animator::set_animation ( const std::string &  animation_name)

◆ set_animation() [2/2]

void Animator::set_animation ( const std::vector< std::reference_wrapper< Texture > > &  frames_)

◆ type_name()

std::string Animator::type_name ( ) const
overridevirtual

Provides a consistent type name for the component.

Returns
A string representing the type name of the component. @CAUTION: All derived components must implement this method to ensure consistent serialization across different compilers and platforms.

Implements Component.

◆ update()

void Animator::update ( float  dt_seconds)
overridevirtual

Implements Component.


The documentation for this class was generated from the following file: