CUGL 2.1
Cornell University Game Library
Public Member Functions | Protected Attributes | List of all members
cugl::scene2::Action Class Reference

#include <CUAction.h>

Inheritance diagram for cugl::scene2::Action:
cugl::scene2::Animate cugl::scene2::FadeIn cugl::scene2::FadeOut cugl::scene2::MoveBy cugl::scene2::MoveTo cugl::scene2::RotateBy cugl::scene2::RotateTo cugl::scene2::ScaleBy cugl::scene2::ScaleTo

Public Member Functions

 Action ()
 
 ~Action ()
 
float getDuration () const
 
void setDuration (float time)
 
virtual std::shared_ptr< Actionclone ()
 
virtual void load (const std::shared_ptr< SceneNode > &target, Uint64 *state)
 
virtual void update (const std::shared_ptr< SceneNode > &target, Uint64 *state, float dt)
 
virtual std::string toString (bool verbose=false) const
 
 operator std::string () const
 

Protected Attributes

float _duration
 

Detailed Description

This class provides an template for an animation action template.

An action contains only the definition of the animation. This can include information about the transform to use or the duration of the animation. However, it does not contain any attribute of the target. Hence, an action can be reapplied to different targets.

By itself, an action does nothing. It only specifies an action that may take place. To use an action, it must be passed to the ActionManager. The manager will create an action instance and animate that instance. While an action may be reused many times, an action instance corresponds to a single animation.

To define a custom action, simply create a subclass and override the uppdate method. This is the method that an action uses to update its target Node.

Constructor & Destructor Documentation

◆ Action()

cugl::scene2::Action::Action ( )
inline

Creates an uninitialized action.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.

◆ ~Action()

cugl::scene2::Action::~Action ( )
inline

Deletes this action, disposing all resources

Member Function Documentation

◆ clone()

virtual std::shared_ptr<Action> cugl::scene2::Action::clone ( )
virtual

◆ getDuration()

float cugl::scene2::Action::getDuration ( ) const
inline

Returns the duration (in seconds) of this animation

Changing this value in mid-animation has undefined side-effects.

Returns
the duration (in seconds) of this animation

◆ load()

virtual void cugl::scene2::Action::load ( const std::shared_ptr< SceneNode > &  target,
Uint64 *  state 
)
inlinevirtual

Prepares a target for action

The important state of the target is stored in the given state parameter. The semantics of this state is action-dependent.

Parameters
targetThe node to act on
stateThe relevant node state

Reimplemented in cugl::scene2::RotateTo, cugl::scene2::ScaleTo, cugl::scene2::MoveTo, cugl::scene2::Animate, cugl::scene2::FadeIn, cugl::scene2::ScaleBy, and cugl::scene2::FadeOut.

◆ operator std::string()

cugl::scene2::Action::operator std::string ( ) const
inline

Cast from an Action to a string.

◆ setDuration()

void cugl::scene2::Action::setDuration ( float  time)
inline

Sets the duration (in seconds) of this animation

Changing this value in mid-animation has undefined side-effects.

Parameters
timethe duration (in seconds) of this animation

◆ toString()

virtual std::string cugl::scene2::Action::toString ( bool  verbose = false) const
virtual

Returns a string representation of the action for debugging purposes.

If verbose is true, the string will include class information. This allows us to unambiguously identify the class.

Parameters
verboseWhether to include class information
Returns
a string representation of this action for debuggging purposes.

Reimplemented in cugl::scene2::RotateTo, cugl::scene2::ScaleTo, cugl::scene2::MoveTo, cugl::scene2::Animate, cugl::scene2::FadeIn, cugl::scene2::ScaleBy, cugl::scene2::RotateBy, cugl::scene2::MoveBy, and cugl::scene2::FadeOut.

◆ update()

virtual void cugl::scene2::Action::update ( const std::shared_ptr< SceneNode > &  target,
Uint64 *  state,
float  dt 
)
inlinevirtual

Executes an action on the given target node.

The important state of the target is stored in the given state parameter. The semantics of this state is action-dependent.

Parameters
targetThe node to act on
stateThe relevant node state
dtThe elapsed time to animate.

Reimplemented in cugl::scene2::RotateTo, cugl::scene2::ScaleTo, cugl::scene2::MoveTo, cugl::scene2::Animate, cugl::scene2::FadeIn, cugl::scene2::ScaleBy, cugl::scene2::RotateBy, cugl::scene2::MoveBy, and cugl::scene2::FadeOut.

Member Data Documentation

◆ _duration

float cugl::scene2::Action::_duration
protected

The duration (in seconds) of the animation


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