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

#include <CURotateAction.h>

Inheritance diagram for cugl::scene2::RotateTo:
cugl::scene2::Action

Public Member Functions

 RotateTo ()
 
 ~RotateTo ()
 
void dispose ()
 
bool init ()
 
bool init (float angle)
 
bool init (float angle, float time)
 
float getAngle () const
 
void setAngle (float angle)
 
virtual std::shared_ptr< Actionclone () override
 
virtual void load (const std::shared_ptr< SceneNode > &target, Uint64 *state) override
 
virtual void update (const std::shared_ptr< SceneNode > &target, Uint64 *state, float dt) override
 
virtual std::string toString (bool verbose=false) const override
 
- Public Member Functions inherited from cugl::scene2::Action
 Action ()
 
 ~Action ()
 
float getDuration () const
 
void setDuration (float time)
 
 operator std::string () const
 

Static Public Member Functions

static std::shared_ptr< RotateToalloc ()
 
static std::shared_ptr< RotateToalloc (float angle)
 
static std::shared_ptr< RotateToalloc (float angle, float time)
 

Protected Attributes

float _angle
 
- Protected Attributes inherited from cugl::scene2::Action
float _duration
 

Detailed Description

This action represents a rotation to a specific angle.

The angle is measured in radians , counter-clockwise from the x-axis.

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.

Constructor & Destructor Documentation

◆ RotateTo()

cugl::scene2::RotateTo::RotateTo ( )
inline

Creates an uninitialized rotation action.

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

◆ ~RotateTo()

cugl::scene2::RotateTo::~RotateTo ( )
inline

Deletes this action instance, disposing all resources

Member Function Documentation

◆ alloc() [1/3]

static std::shared_ptr<RotateTo> cugl::scene2::RotateTo::alloc ( )
inlinestatic

Returns a newly allocated rotation action towards the x-axis

The target angle is set to 0.0. Because of how rotatations are interpolated, this guarantees that the rotation will be clockwise. The animation will be instantaneous.

Returns
a newly allocated rotation action towards the x-axis

◆ alloc() [2/3]

static std::shared_ptr<RotateTo> cugl::scene2::RotateTo::alloc ( float  angle)
inlinestatic

Returns a newly allocated rotation action towards the given angle

This angle is measured in radians, counter-clockwise from the x-axis. The animation will be counter-clockwise if the target angle is larger than the current one. Otherwise it will be clockwise. The animation will be instantaneous.

Parameters
angleThe target rotation angle
Returns
a newly allocated rotation action towards the given angle

◆ alloc() [3/3]

static std::shared_ptr<RotateTo> cugl::scene2::RotateTo::alloc ( float  angle,
float  time 
)
inlinestatic

Returns a newly allocated rotation action towards the given angle

This angle is measured in radians, counter-clockwise from the x-axis. The animation will be counter-clockwise if the target angle is larger than the current one. Otherwise it will be clockwise. The animation will take place over the given number of seconds.

Parameters
angleThe target rotation angle
timeThe animation duration
Returns
a newly allocated rotation action towards the given angle

◆ clone()

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

Returns a newly allocated copy of this Action.

Returns
a newly allocated copy of this Action.

Reimplemented from cugl::scene2::Action.

◆ dispose()

void cugl::scene2::RotateTo::dispose ( )
inline

Disposes all of the resources used by this action.

A disposed action can be safely reinitialized.

◆ getAngle()

float cugl::scene2::RotateTo::getAngle ( ) const
inline

Returns the rotation target angle for this action.

Changing this value for an actively animating action can have undefined effects.

Returns
the rotation target angle for this action.

◆ init() [1/3]

bool cugl::scene2::RotateTo::init ( )
inline

Initializes a rotation action towards the x-axis

The target angle is set to 0.0. Because of how rotatations are interpolated, this guarantees that the rotation will be clockwise. The animation will be instantaneous.

Returns
true if initialization was successful.

◆ init() [2/3]

bool cugl::scene2::RotateTo::init ( float  angle)
inline

Initializes a rotation action towards the given angle

This angle is measured in radians, counter-clockwise from the x-axis.
The animation will be counter-clockwise if the target angle is larger than the current one. Otherwise it will be clockwise. The animation will be instantaneous.

Parameters
angleThe target rotation angle
Returns
true if initialization was successful.

◆ init() [3/3]

bool cugl::scene2::RotateTo::init ( float  angle,
float  time 
)

Initializes a rotation action towards the given angle

This angle is measured in radians, counter-clockwise from the x-axis. The animation will be counter-clockwise if the target angle is larger than the current one. Otherwise it will be clockwise. The animation will take place over the given number of seconds.

Parameters
angleThe target rotation angle
timeThe animation duration
Returns
true if initialization was successful.

◆ load()

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

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 from cugl::scene2::Action.

◆ setAngle()

void cugl::scene2::RotateTo::setAngle ( float  angle)
inline

Sets the rotation target angle for this action.

Changing this value for an actively animating action can have undefined effects.

Parameters
angleThe rotation target angle for this action.

◆ toString()

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

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 from cugl::scene2::Action.

◆ update()

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

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 from cugl::scene2::Action.

Member Data Documentation

◆ _angle

float cugl::scene2::RotateTo::_angle
protected

The target angle for this action


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