nomlib
Loading...
Searching...
No Matches
nom::AnimateTexturesAction Class Reference

Animate changes to a sprite's texture. More...

#include <AnimateTexturesAction.hpp>

Inheritance diagram for nom::AnimateTexturesAction:
[legend]

Public Types

typedef AnimateTexturesAction self_type
typedef IActionObject derived_type
Public Types inherited from nom::IActionObject
enum  FrameState { COMPLETED , PLAYING }
 The update status of the action. More...
typedef IActionObject self_type
typedef std::function< real32(real32, real32, real32, real32)> timing_curve_func
 A function pointer to a timing mode.

Public Member Functions

 AnimateTexturesAction (const std::shared_ptr< Sprite > &drawable, const texture_frames &textures, real32 frame_interval_seconds)
 Animate changes to a sprite’s texture.
virtual std::unique_ptr< IActionObject > clone () const override
 Create a deep copy instance of the action.
virtual IActionObject::FrameState next_frame (real32 delta_time) override
 Play the action forward in time by one time step.
virtual IActionObject::FrameState prev_frame (real32 delta_time) override
 Play the action backwards in time by one time step.
virtual void pause (real32 delta_time) override
 Freeze the action's internal state.
virtual void resume (real32 delta_time) override
 Resume the internal state of the action.
virtual void rewind (real32 delta_time) override
 Reset the internal state of the action back to its initial starting values.
virtual void release () override
 Free externally referenced resources held by the action.
Public Member Functions inherited from nom::IActionObject
const std::string & name () const
 Get the unique identifier of the action.
real32 duration () const
 Get the duration of the action.
real32 speed () const
 Get the speed modifier of the action.
const IActionObject::timing_curve_functiming_curve () const
 Get the timing mode function used by the action.
void set_name (const std::string &action_id)
 Set the unique identifier of the action.
virtual void set_speed (real32 speed)
 Set the speed factor of the action.
virtual void set_timing_curve (const IActionObject::timing_curve_func &mode)
 Set the timing mode of the action.

Private Types

typedef texture_frames::iterator frame_iterator

Private Member Functions

void initialize (const texture_frames &textures, real32 frame_interval)
IActionObject::FrameState update (real32 t, real32 b, real32 c, real32 d)
void first_frame (real32 delta_time)
void last_frame (real32 delta_time)

Private Attributes

real32 total_displacement_
 The total number of textures to animate.
uint32 initial_frame_
 The initial starting texture to animate from.
texture_frames frames_
 The stored textures.
frame_iterator next_frame_
frame_iterator last_frame_
std::shared_ptr< Spritedrawable_
 The provided drawable used to render frames to.
real32 frame_interval_
 The delay (in seconds) before displaying the next texture.
real32 last_delta_

Static Private Attributes

static const char * DEBUG_CLASS_NAME

Friends

class ActionTest
 Allow access into our private parts for unit testing.

Additional Inherited Members

Protected Member Functions inherited from nom::IActionObject
IActionObject::FrameState status () const
 Get the current state of the action.
void set_duration (real32 seconds)
 Set the duration of the action.
void set_status (FrameState state)
 Set the state of the action.
Protected Attributes inherited from nom::IActionObject
real32 elapsed_frames_ = 0.0f
 Internal frames counter.
Timer timer_
 Internal time clock (milliseconds resolution).

Detailed Description

Animate changes to a sprite's texture.

...

Remarks
This action is reversible; the sprite sheet frames are displayed in the inverse order. For example, if the sprite sheet frames are {0, 1, 2}, the reversed order would be {2, 1, 0}.

Definition at line 47 of file AnimateTexturesAction.hpp.

Member Typedef Documentation

◆ derived_type

typedef IActionObject nom::AnimateTexturesAction::derived_type

Definition at line 54 of file AnimateTexturesAction.hpp.

◆ frame_iterator

typedef texture_frames::iterator nom::AnimateTexturesAction::frame_iterator
private

Definition at line 97 of file AnimateTexturesAction.hpp.

◆ self_type

typedef AnimateTexturesAction nom::AnimateTexturesAction::self_type

Definition at line 53 of file AnimateTexturesAction.hpp.

Constructor & Destructor Documentation

◆ AnimateTexturesAction()

nom::AnimateTexturesAction::AnimateTexturesAction ( const std::shared_ptr< Sprite > & drawable,
const texture_frames & textures,
real32 frame_interval_seconds )

Animate changes to a sprite’s texture.

Parameters
drawableA valid nom::Sprite instance to use in rendering the frames to.
texturesA collection of textures to use to animate the sprite. sprite.
frame_interval_secondsThe duration (in seconds) that each texture is displayed.

Member Function Documentation

◆ clone()

virtual std::unique_ptr< IActionObject > nom::AnimateTexturesAction::clone ( ) const
overridevirtual

Create a deep copy instance of the action.

Remarks
A cloned instance is created using the action's attributes at the time of construction. External resources of the action – i.e.: nom::Sprite – are not modified, and you may need to reset the state appropriately if the action has been ran previously.

Implements nom::IActionObject.

◆ next_frame()

virtual IActionObject::FrameState nom::AnimateTexturesAction::next_frame ( real32 delta_time)
overridevirtual

Play the action forward in time by one time step.

Parameters
delta_timeReserved for application-defined implementations.
Note
This method should not normally need to be called externally! Exceptions might include: a) implementing a new action; b) advanced debugging
See also
nom::DispatchQueue

Implements nom::IActionObject.

◆ pause()

virtual void nom::AnimateTexturesAction::pause ( real32 delta_time)
overridevirtual

Freeze the action's internal state.

Parameters
delta_timeReserved for application-defined implementations.
Note
This method should not normally need to be called externally! Exceptions might include: a) implementing a new action; b) advanced debugging
See also
nom::DispatchQueue

Implements nom::IActionObject.

◆ prev_frame()

virtual IActionObject::FrameState nom::AnimateTexturesAction::prev_frame ( real32 delta_time)
overridevirtual

Play the action backwards in time by one time step.

Parameters
delta_timeReserved for application-defined implementations.
Note
This method should not normally need to be called externally! Exceptions might include: a) implementing a new action; b) advanced debugging
Remarks
Not all actions are reversible – see the action's documentation for its implementation details.
See also
nom::ReversedAction

Implements nom::IActionObject.

◆ release()

virtual void nom::AnimateTexturesAction::release ( )
overridevirtual

Free externally referenced resources held by the action.

Note
This method should not normally need to be called externally! Exceptions might include: a) implementing a new action; b) advanced debugging
See also
nom::RemoveAction

Implements nom::IActionObject.

◆ resume()

virtual void nom::AnimateTexturesAction::resume ( real32 delta_time)
overridevirtual

Resume the internal state of the action.

Parameters
delta_timeReserved for application-defined implementations.
Note
This method should not normally need to be called externally! Exceptions might include: a) implementing a new action; b) advanced debugging
See also
nom::DispatchQueue

Implements nom::IActionObject.

◆ rewind()

virtual void nom::AnimateTexturesAction::rewind ( real32 delta_time)
overridevirtual

Reset the internal state of the action back to its initial starting values.

Parameters
delta_timeReserved for application-defined implementations.
Note
This method should not normally need to be called externally! Exceptions might include: a) implementing a new action; b) advanced debugging
See also
nom::RepeatForAction, nom::RepeatForeverAction

Implements nom::IActionObject.

◆ ActionTest

friend class ActionTest
friend

Allow access into our private parts for unit testing.

Definition at line 51 of file AnimateTexturesAction.hpp.

Member Data Documentation

◆ DEBUG_CLASS_NAME

const char* nom::AnimateTexturesAction::DEBUG_CLASS_NAME
staticprivate

Definition at line 87 of file AnimateTexturesAction.hpp.

◆ drawable_

std::shared_ptr<Sprite> nom::AnimateTexturesAction::drawable_
private

The provided drawable used to render frames to.

Definition at line 111 of file AnimateTexturesAction.hpp.

◆ frame_interval_

real32 nom::AnimateTexturesAction::frame_interval_
private

The delay (in seconds) before displaying the next texture.

Definition at line 114 of file AnimateTexturesAction.hpp.

◆ frames_

texture_frames nom::AnimateTexturesAction::frames_
private

The stored textures.

Definition at line 106 of file AnimateTexturesAction.hpp.

◆ initial_frame_

uint32 nom::AnimateTexturesAction::initial_frame_
private

The initial starting texture to animate from.

Definition at line 103 of file AnimateTexturesAction.hpp.

◆ last_delta_

real32 nom::AnimateTexturesAction::last_delta_
private

Definition at line 115 of file AnimateTexturesAction.hpp.

◆ last_frame_

frame_iterator nom::AnimateTexturesAction::last_frame_
private

Definition at line 108 of file AnimateTexturesAction.hpp.

◆ next_frame_

frame_iterator nom::AnimateTexturesAction::next_frame_
private

Definition at line 107 of file AnimateTexturesAction.hpp.

◆ total_displacement_

real32 nom::AnimateTexturesAction::total_displacement_
private

The total number of textures to animate.

Definition at line 100 of file AnimateTexturesAction.hpp.


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