Public Member Functions | Friends | List of all members
ime::AnimationFrame Class Reference

An Animation frame. More...

#include <AnimationFrame.h>

Public Member Functions

 AnimationFrame (unsigned int rectLeft, unsigned int rectTop, unsigned int rectWidth, unsigned int rectHeight)
 Construct the frame from its coordinates. More...
 
 AnimationFrame (const UIntRect &rect)
 Construct the frame from. More...
 
 AnimationFrame (const AnimationFrame &)=default
 Copy constructor. More...
 
AnimationFrameoperator= (const AnimationFrame &)=default
 Copy assignment operator. More...
 
void setName (const std::string &name)
 Set the name of the frame. More...
 
const std::string & getName () const
 Get the name of the frame. More...
 
const UIntRectgetSpritesheetRect () const
 Get position information of the frame on the Spritesheet. More...
 
bool isCurrent () const
 Check if the frame is currently displayed by the animation. More...
 
unsigned int getIndex () const
 Get the position of the frame in the animation sequence. More...
 

Friends

class Animation
 

Detailed Description

An Animation frame.

Definition at line 36 of file AnimationFrame.h.

Constructor & Destructor Documentation

◆ AnimationFrame() [1/3]

ime::AnimationFrame::AnimationFrame ( unsigned int  rectLeft,
unsigned int  rectTop,
unsigned int  rectWidth,
unsigned int  rectHeight 
)

Construct the frame from its coordinates.

Parameters
rectLeftLeft coordinate of the frame
rectTopTop coordinate of the frame
rectWidthWidth of the frame
rectHeightHeight of the frame
Note
the last two parameters are the width and height, not the right and bottom coordinates!

◆ AnimationFrame() [2/3]

ime::AnimationFrame::AnimationFrame ( const UIntRect rect)

Construct the frame from.

Parameters
rect

◆ AnimationFrame() [3/3]

ime::AnimationFrame::AnimationFrame ( const AnimationFrame )
default

Copy constructor.

Member Function Documentation

◆ getIndex()

unsigned int ime::AnimationFrame::getIndex ( ) const

Get the position of the frame in the animation sequence.

Returns
The index of the frame in the animation sequence

◆ getName()

const std::string & ime::AnimationFrame::getName ( ) const

Get the name of the frame.

Returns
The name of the frame
See also
setName

◆ getSpritesheetRect()

const UIntRect & ime::AnimationFrame::getSpritesheetRect ( ) const

Get position information of the frame on the Spritesheet.

Returns
Position information on the animations spritesheet

◆ isCurrent()

bool ime::AnimationFrame::isCurrent ( ) const

Check if the frame is currently displayed by the animation.

Returns
True if currently displayed, otherwise false

◆ operator=()

AnimationFrame & ime::AnimationFrame::operator= ( const AnimationFrame )
default

Copy assignment operator.

◆ setName()

void ime::AnimationFrame::setName ( const std::string &  name)

Set the name of the frame.

Parameters
nameThe name of the frame

The name property allows you to retrieve or remove an animation frame from an Animation by its name instead of its index. Here is an example that plays an explosion effect when the animation reaches the 3rd frame:

ime::Animation::Ptr explosionAnim = ime::Animation::create("explosion", spritesheet, ime::seconds(5));
explosionAnim->addFrame(ime::Index{0, 0}, 5);
explosionAnim->getFrame(2).setName("audioTrigger");
...
if (animator.getCurrentFrame().getName() == "audioTrigger")
explosionSfx.play()
std::shared_ptr< Animation > Ptr
Shared animation pointer.
Definition: Animation.h:53
static Animation::Ptr create(const std::string &name, const SpriteSheet &spriteSheet, const Time &duration=Time::Zero)
Create a new Animation object.
Represents a position Grid2D Tile.
Definition: Index.h:35

By default the frame name is an empty string

See also
getName

Friends And Related Function Documentation

◆ Animation

friend class Animation
friend

Definition at line 124 of file AnimationFrame.h.


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