FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::Animation Class Reference

Class that represent/handle an animation. More...

#include <C_animation.hpp>

Inheritance diagram for fge::Animation:
fge::manager::BaseDataAccessor< manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >, manager::DataAccessorOptions::BLOCKPOINTER_ONLY >

Public Types

using Index = uint16_t
 
using SharedDataType
 
using SharedType
 

Public Member Functions

 Animation (std::string_view name, Index frame=0)
 Constructor that takes the name of the animation.
 
 Animation (std::string_view name, std::string_view group, Index frame=0)
 Constructor that takes the name of the animation and the group name.
 
 Animation (char const name[], Index frame=0)
 
 Animation (char const name[], char const group[], Index frame=0)
 
 Animation (SharedDataType data, Index frame=0)
 
 Animation (SharedDataType data, std::string_view group, Index frame=0)
 
 Animation (SharedDataType data, char const group[], Index frame=0)
 
void clear () override
 Clear the animation.
 
anim::AnimationType getType () const
 Get the type of the loaded animation.
 
bool setGroup (std::string_view group)
 Set the group of the animation by its name.
 
bool setGroup (Index groupIndex)
 Set the group of the animation by its index.
 
anim::AnimationGroup const * getGroup () const
 Get the actual group of the animation.
 
anim::AnimationGroupgetGroup ()
 
anim::AnimationGroup const * getGroup (std::string_view group) const
 Get the group of the animation by its name.
 
anim::AnimationGroupgetGroup (std::string_view group)
 
anim::AnimationGroup const * getGroup (Index groupIndex) const
 Get the group of the animation by its index.
 
anim::AnimationGroupgetGroup (Index groupIndex)
 
bool isGroupValid () const
 Check if the actual group is valid.
 
Index nextFrame ()
 Go to the next frame of the animation.
 
void setFrame (Index frame)
 Set the frame of the animation.
 
Index getFrameIndex () const
 Get the actual frame index of the animation.
 
Index getGroupIndex () const
 Get the actual group index of the animation.
 
fge::anim::AnimationFrame const * getFrame () const
 Get the actual frame of the animation.
 
fge::anim::AnimationFramegetFrame ()
 
fge::anim::AnimationFrame const * getFrame (Index frameIndex) const
 Get the frame of the animation by its index.
 
fge::anim::AnimationFramegetFrame (Index frameIndex)
 
bool isFrameValid () const
 Check if the actual frame is valid.
 
void setLoop (bool active)
 Set the loop mode of the animation.
 
bool isLoop () const
 Check if the loop mode is active.
 
void setReverse (bool active)
 Set the reverse mode of the animation.
 
bool isReverse () const
 Check if the reverse mode is active.
 
void setHorizontalFlip (bool active)
 Set the horizontal flip mode of the animation.
 
bool isHorizontalFlipped () const
 Check if the horizontal flip mode is active.
 
std::shared_ptr< fge::TextureType > const & retrieveTexture () const
 Retrieve the texture of the actual frame.
 
fge::RectInt retrieveTextureRect () const
 Get the texture rectangle if the type of the animation is fge::anim::ANIM_TYPE_TILESET of the actual frame.
 
void reload ()
 Reload the cached resource from the same name.
 
bool valid () const
 Check if the font is valid (not unloaded)
 
SharedDataType const & getSharedBlock () const
 Get the resource block data.
 
SharedType const & getSharedData () const
 Get the shared resource data.
 
std::string const & getName () const
 Get the name of the resource.
 
manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >::Manager::DataType * retrieve ()
 Retrieve the raw shared pointer from the current resource.
 
manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >::Manager::DataType const * retrieve () const
 

Detailed Description

Class that represent/handle an animation.

Constructor & Destructor Documentation

◆ Animation() [1/2]

fge::Animation::Animation ( std::string_view name,
Index frame = 0 )

Constructor that takes the name of the animation.

This function will get the animation data from the animation manager and load the first group index.

Parameters
nameThe name of the animation
frameThe beginning frame of the animation

◆ Animation() [2/2]

fge::Animation::Animation ( std::string_view name,
std::string_view group,
Index frame = 0 )

Constructor that takes the name of the animation and the group name.

This function will get the animation data from the animation manager and load the wanted group by its name.

Parameters
nameThe name of the animation
groupThe name of the group
frameThe beginning frame of the animation

Member Function Documentation

◆ clear()

◆ getFrame() [1/2]

fge::anim::AnimationFrame const * fge::Animation::getFrame ( ) const
nodiscard

Get the actual frame of the animation.

Returns
The frame data or nullptr

◆ getFrame() [2/2]

fge::anim::AnimationFrame const * fge::Animation::getFrame ( Index frameIndex) const
nodiscard

Get the frame of the animation by its index.

Returns
The frame data or nullptr

◆ getFrameIndex()

Index fge::Animation::getFrameIndex ( ) const
nodiscard

Get the actual frame index of the animation.

Returns
The frame index

◆ getGroup() [1/3]

anim::AnimationGroup const * fge::Animation::getGroup ( ) const
nodiscard

Get the actual group of the animation.

Returns
The group data or nullptr

◆ getGroup() [2/3]

anim::AnimationGroup const * fge::Animation::getGroup ( Index groupIndex) const
nodiscard

Get the group of the animation by its index.

Parameters
groupIndexThe index of the group
Returns
The group data or nullptr

◆ getGroup() [3/3]

anim::AnimationGroup const * fge::Animation::getGroup ( std::string_view group) const
nodiscard

Get the group of the animation by its name.

Parameters
groupThe name of the group
Returns
The group data or nullptr

◆ getGroupIndex()

Index fge::Animation::getGroupIndex ( ) const
nodiscard

Get the actual group index of the animation.

Returns
The group index

◆ getName()

std::string const & fge::manager::BaseDataAccessor< manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >, TOption >::getName ( ) const
nodiscardinherited

Get the name of the resource.

Returns
The name of the resource, or an empty string if the resource is not valid

◆ getSharedBlock()

BaseDataAccessor< manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >, TOption >::SharedDataType const & fge::manager::BaseDataAccessor< manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >, TOption >::getSharedBlock ( ) const
nodiscardinherited

Get the resource block data.

Warning
If ALLOW_VARIANT_OF_DATAPOINTER_AND_BLOCKPOINTER is set, this method can a "bad" element.
Returns
The resource block data

◆ getSharedData()

BaseDataAccessor< manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >, TOption >::SharedType const & fge::manager::BaseDataAccessor< manager::GlobalDataAccessorManagerInfo< anim::AnimationManager, &anim::gManager >, TOption >::getSharedData ( ) const
nodiscardinherited

Get the shared resource data.

Returns
The shared resource data

◆ getType()

anim::AnimationType fge::Animation::getType ( ) const
nodiscard

Get the type of the loaded animation.

Returns
The type of the loaded animation

◆ isFrameValid()

bool fge::Animation::isFrameValid ( ) const
nodiscard

Check if the actual frame is valid.

Returns
The validity of the actual frame

◆ isGroupValid()

bool fge::Animation::isGroupValid ( ) const
nodiscard

Check if the actual group is valid.

Returns
The validity of the actual group

◆ isHorizontalFlipped()

bool fge::Animation::isHorizontalFlipped ( ) const
nodiscard

Check if the horizontal flip mode is active.

Returns
true if the horizontal flip mode is active, false otherwise

◆ isLoop()

bool fge::Animation::isLoop ( ) const
nodiscard

Check if the loop mode is active.

Returns
true if the loop mode is active, false otherwise

◆ isReverse()

bool fge::Animation::isReverse ( ) const
nodiscard

Check if the reverse mode is active.

Returns
true if the reverse mode is active, false otherwise

◆ nextFrame()

Index fge::Animation::nextFrame ( )

Go to the next frame of the animation.

Returns
The new frame index

◆ reload()

Reload the cached resource from the same name.

◆ retrieve()

Retrieve the raw shared pointer from the current resource.

Warning
Will never be nullptr if the manager was correctly initialized.
Returns
The raw resource pointer

◆ retrieveTexture()

std::shared_ptr< fge::TextureType > const & fge::Animation::retrieveTexture ( ) const
nodiscard

Retrieve the texture of the actual frame.

Returns
The texture or texture::GetBadTexture if something is invalid

◆ retrieveTextureRect()

fge::RectInt fge::Animation::retrieveTextureRect ( ) const
nodiscard

Get the texture rectangle if the type of the animation is fge::anim::ANIM_TYPE_TILESET of the actual frame.

Returns
The texture rectangle or {0,0,16,16} if something is invalid

◆ setFrame()

void fge::Animation::setFrame ( Index frame)

Set the frame of the animation.

Parameters
frameThe new frame index

◆ setGroup() [1/2]

bool fge::Animation::setGroup ( Index groupIndex)

Set the group of the animation by its index.

Parameters
groupIndexThe index of the group
Returns
true if the group was found, false otherwise

◆ setGroup() [2/2]

bool fge::Animation::setGroup ( std::string_view group)

Set the group of the animation by its name.

Parameters
groupThe name of the group
Returns
true if the group was found, false otherwise

◆ setHorizontalFlip()

void fge::Animation::setHorizontalFlip ( bool active)

Set the horizontal flip mode of the animation.

Parameters
activetrue to enable flip, false otherwise

◆ setLoop()

void fge::Animation::setLoop ( bool active)

Set the loop mode of the animation.

Parameters
activetrue to enable the loop mode, false otherwise

◆ setReverse()

void fge::Animation::setReverse ( bool active)

Set the reverse mode of the animation.

Parameters
activetrue to enable the reverse mode, false otherwise

◆ valid()

Check if the font is valid (not unloaded)

Returns
True if the font is valid, false otherwise

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