CUGL 2.3
Cornell University Game Library
|
#include <CUAnimateAction.h>
Public Member Functions | |
Animate () | |
~Animate () | |
void | dispose () |
bool | init () |
bool | init (int start, int end, float time, int repeat=1) |
bool | init (const std::vector< int > &frames, float time) |
bool | init (const std::vector< int > &frames, const std::vector< float > &time) |
int | getFrame (float t) const |
const std::vector< int > & | getSequence () const |
const std::vector< float > & | getTimeSteps () const |
void | setSequence (const std::vector< int > &frames) |
void | setSequence (const std::vector< int > &frames, const std::vector< float > &time) |
int | isUniform () const |
void | setUniform () |
virtual std::shared_ptr< Action > | clone () 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) |
virtual std::shared_ptr< Action > | clone () |
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 | |
Static Public Member Functions | |
static std::shared_ptr< Animate > | alloc () |
static std::shared_ptr< Animate > | alloc (int start, int end, float time, int repeat=1) |
static std::shared_ptr< Animate > | alloc (const std::vector< int > &frames, float time) |
static std::shared_ptr< Animate > | alloc (const std::vector< int > &frames, const std::vector< float > &time) |
Protected Attributes | |
std::vector< int > | _frameset |
std::vector< float > | _timestep |
bool | _uniform |
Protected Attributes inherited from cugl::scene2::Action | |
float | _duration |
This action represents a sequence of film-strip frames for animation
Each frame in the sequence is given a set amount of time to display. The animation will not tween between frames. To do so would require a refactoring of the scene graph nodes.
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.
|
inline |
Creates an uninitialized animation action.
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.
|
inline |
Deletes this action instance, disposing all resources
|
inlinestatic |
Returns a newly allocated, degenerate animation action.
The animation sequence is empty, meaning no animation takes place.
|
inlinestatic |
Returns a newly allocated animation sequence of variable speed
The animation sequence is given by the first specified vector. The second vector specifies the number of seconds to spend on each frame. the overall animation duration is the sum of this vector.
Both vectors must be the same length. They can be empty.
frames | The animation sequence |
time | The duration of each frame in the sequences |
|
inlinestatic |
Returns a newly allocated animation sequence of uniform speed
The animation sequence is given by the specified vector. The animation will spend an equal amount of time on each frame, so that the total time spent animating is the one specified.
frames | The animation sequence |
time | The animation duration |
|
inlinestatic |
Returns a newly allocated animation sequence of frames start to end (inclusive).
The animation sequence has start as its first frame and end as its last. Animation will be in frame order, with an equal amount of time spent on each frame. The value start must be less than (or equal to) end, as this action does not know the filmstrip length.\
The repeat argument is optional. It specifies the number of time to repeat the animation sequence. The total animation time will include all repeats.
start | The initial frame to animate |
end | The final frame to animate |
time | The animation duration |
repeat | The number of times to repeat the sequence |
|
overridevirtual |
Returns a newly allocated copy of this Action.
Reimplemented from cugl::scene2::Action.
void cugl::scene2::Animate::dispose | ( | ) |
Disposes all of the resources used by this action.
A disposed action can be safely reinitialized.
int cugl::scene2::Animate::getFrame | ( | float | t | ) | const |
Returns the frame in the filmstrip to be animated at time index t in [0,1]
|
inline |
Returns the sequence of frames used in this animation
Changing this value for an actively animating action can have undefined effects.
|
inline |
Returns individual time steps for each frame
If this animation uses a uniform time step for each frame, this set will be empty.
Changing this value for an actively animating action can have undefined effects.
|
inline |
Initializes a degenerate animation action.
The animation sequence is empty, meaning no animation takes place.
bool cugl::scene2::Animate::init | ( | const std::vector< int > & | frames, |
const std::vector< float > & | time | ||
) |
Initializes an animation sequence of variable speed
The animation sequence is given by the first specified vector. The second vector specifies the number of seconds to spend on each frame. the overall animation duration is the sum of this vector.
Both vectors must be the same length. They can be empty.
frames | The animation sequence |
time | The duration of each frame in the sequences |
bool cugl::scene2::Animate::init | ( | const std::vector< int > & | frames, |
float | time | ||
) |
Initializes an animation sequence of uniform speed
The animation sequence is given by the specified vector. The animation will spend an equal amount of time on each frame, so that the total time spent animating is the one specified.
frames | The animation sequence |
time | The animation duration |
bool cugl::scene2::Animate::init | ( | int | start, |
int | end, | ||
float | time, | ||
int | repeat = 1 |
||
) |
Initializes an animation sequence of frames start to end (inclusive).
The animation sequence has start as its first frame and end as its last. Animation will be in frame order, with an equal amount of time spent on each frame. The value start must be less than (or equal to) end, as this action does not know the filmstrip length.
The repeat argument is optional. It specifies the number of time to repeat the animation sequence. The total animation time will include all repeats.
start | The initial frame to animate |
end | The final frame to animate |
time | The animation duration |
repeat | The number of times to repeat the sequence |
|
inline |
Returns true if this animation uses a uniform time step for all frames
Changing this value for an actively animating action can have undefined effects.
|
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.
target | The node to act on |
state | The relevant node state |
Reimplemented from cugl::scene2::Action.
void cugl::scene2::Animate::setSequence | ( | const std::vector< int > & | frames | ) |
Sets the sequence of frames used in this animation
If this set has a different size than the one initial set, this setter will keep the overall animation duration, but will revert to a uniform time step.
Changing this value for an actively animating action can have undefined effects.
frames | the sequence of frames used in this animation |
void cugl::scene2::Animate::setSequence | ( | const std::vector< int > & | frames, |
const std::vector< float > & | time | ||
) |
Sets the sequence of frames used in this animation
Both vectors must be the same length. They can be empty.
Changing this value for an actively animating action can have undefined effects.
frames | the sequence of frames used in this animation |
time | the time to devote animating each frame |
void cugl::scene2::Animate::setUniform | ( | ) |
Forces this animation to use a uniform time step for all frames
Changing this value for an actively animating action can have undefined effects.
|
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.
verbose | Whether to include class information |
Reimplemented from cugl::scene2::Action.
|
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.
target | The node to act on |
state | The relevant node state |
dt | The elapsed time to animate. |
Reimplemented from cugl::scene2::Action.
|
protected |
The list of frames to animate
|
protected |
The amount of time for each frame
|
protected |
Whether or not the timestep is uniform