galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::graphics::Animation Class Referencefinal

2D animation information. More...

#include <Animation.hpp>

+ Collaboration diagram for galaxy::graphics::Animation:

Public Member Functions

 Animation ()
 Constructor.
 
 Animation (Animation &&)
 Move constructor.
 
Animationoperator= (Animation &&)
 Move assignment operator.
 
 Animation (const Animation &)
 Copy constructor.
 
Animationoperator= (const Animation &)
 Copy assignment operator.
 
 ~Animation ()
 Destructor.
 
bool load (const std::string &file)
 Load a json file from VFS and set frames from that.
 
void set_frames (const nlohmann::json &json)
 Loads frames from json object.
 
void set_frames (const meta::vector< Frame > &frames)
 Set from an existing vector of frames.
 
void next ()
 Advance to the next frame.
 
void prev ()
 Go back to the previous frame.
 
void restart ()
 Sets animation back to beginning.
 
Framecurrent ()
 Get currently active frame.
 
std::size_t total () const
 Get total frames.
 
std::size_t index () const
 Get current frame index.
 
meta::vector< Frame > & frames ()
 Get the frames.
 

Public Attributes

double m_speed
 Speed of the animation. Multiplier, so 1.0f is regular speed.
 
std::string m_name
 Animation name.
 

Private Attributes

std::size_t m_index
 Index of the current active frame.
 
meta::vector< Framem_frames
 Frames belonging to this animation.
 

Detailed Description

2D animation information.

Definition at line 27 of file Animation.hpp.

Constructor & Destructor Documentation

◆ Animation() [1/3]

galaxy::graphics::Animation::Animation ( )

Constructor.

Definition at line 19 of file Animation.cpp.

◆ Animation() [2/3]

galaxy::graphics::Animation::Animation ( Animation && a)

Move constructor.

Definition at line 25 of file Animation.cpp.

◆ Animation() [3/3]

galaxy::graphics::Animation::Animation ( const Animation & a)

Copy constructor.

Definition at line 46 of file Animation.cpp.

◆ ~Animation()

galaxy::graphics::Animation::~Animation ( )

Destructor.

Definition at line 67 of file Animation.cpp.

Member Function Documentation

◆ operator=() [1/2]

Animation & galaxy::graphics::Animation::operator= ( Animation && a)

Move assignment operator.

Definition at line 33 of file Animation.cpp.

◆ operator=() [2/2]

Animation & galaxy::graphics::Animation::operator= ( const Animation & a)

Copy assignment operator.

Definition at line 54 of file Animation.cpp.

◆ load()

bool galaxy::graphics::Animation::load ( const std::string & file)
nodiscard

Load a json file from VFS and set frames from that.

Parameters
fileFile in VFS. JSON file must be an array.
Returns
True if successful.

Definition at line 71 of file Animation.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_frames() [1/2]

void galaxy::graphics::Animation::set_frames ( const nlohmann::json & json)

Loads frames from json object.

Parameters
jsonMust be an array of json objects.

Definition at line 88 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ set_frames() [2/2]

void galaxy::graphics::Animation::set_frames ( const meta::vector< Frame > & frames)

Set from an existing vector of frames.

Parameters
framesList of frames to use for this animation.

Definition at line 101 of file Animation.cpp.

+ Here is the call graph for this function:

◆ next()

void galaxy::graphics::Animation::next ( )

Advance to the next frame.

Definition at line 106 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ prev()

void galaxy::graphics::Animation::prev ( )

Go back to the previous frame.

Definition at line 116 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ restart()

void galaxy::graphics::Animation::restart ( )

Sets animation back to beginning.

Definition at line 126 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ current()

Frame & galaxy::graphics::Animation::current ( )
nodiscard

Get currently active frame.

Returns
Reference to active frame.

Definition at line 131 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ total()

std::size_t galaxy::graphics::Animation::total ( ) const
nodiscard

Get total frames.

Returns
std::size_t.

Definition at line 136 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ index()

std::size_t galaxy::graphics::Animation::index ( ) const
nodiscard

Get current frame index.

Returns
std::size_t.

Definition at line 141 of file Animation.cpp.

+ Here is the caller graph for this function:

◆ frames()

meta::vector< Frame > & galaxy::graphics::Animation::frames ( )
nodiscard

Get the frames.

Returns
Reference to frame list.

Definition at line 146 of file Animation.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_speed

double galaxy::graphics::Animation::m_speed

Speed of the animation. Multiplier, so 1.0f is regular speed.

Definition at line 136 of file Animation.hpp.

◆ m_name

std::string galaxy::graphics::Animation::m_name

Animation name.

Definition at line 141 of file Animation.hpp.

◆ m_index

std::size_t galaxy::graphics::Animation::m_index
private

Index of the current active frame.

Definition at line 147 of file Animation.hpp.

◆ m_frames

meta::vector<Frame> galaxy::graphics::Animation::m_frames
private

Frames belonging to this animation.

Definition at line 152 of file Animation.hpp.


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