CUGL 1.3
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
CUAction.h
1 //
2 // CUAction.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides support for animation actions. Actions are primitive
6 // tweening operations on scene graph nodes. They take an start state and an
7 // end state and linearly interpolate them over a period of time. Examples of
8 // such operations include Move, Scale, Rotate, Fade, and Animate.
9 //
10 // This class uses our standard shared-pointer architecture.
11 //
12 // 1. The constructor does not perform any initialization; it just sets all
13 // attributes to their defaults.
14 //
15 // 2. All initialization takes place via init methods, which can fail if an
16 // object is initialized more than once.
17 //
18 // 3. All allocation takes place via static constructors which return a shared
19 // pointer.
20 //
21 // CUGL MIT License:
22 // This software is provided 'as-is', without any express or implied
23 // warranty. In no event will the authors be held liable for any damages
24 // arising from the use of this software.
25 //
26 // Permission is granted to anyone to use this software for any purpose,
27 // including commercial applications, and to alter it and redistribute it
28 // freely, subject to the following restrictions:
29 //
30 // 1. The origin of this software must not be misrepresented; you must not
31 // claim that you wrote the original software. If you use this software
32 // in a product, an acknowledgment in the product documentation would be
33 // appreciated but is not required.
34 //
35 // 2. Altered source versions must be plainly marked as such, and must not
36 // be misrepresented as being the original software.
37 //
38 // 3. This notice may not be removed or altered from any source distribution.
39 //
40 // Author: Sophie Huang and Walker White
41 // Version: 3/12/17
42 //
43 #ifndef __CU_ACTION_H__
44 #define __CU_ACTION_H__
45 
46 #include <cugl/math/cu_math.h>
47 #include <cugl/2d/CUNode.h>
48 #include <cugl/2d/CUPolygonNode.h>
49 #include <SDL/SDL.h>
50 
51 namespace cugl {
52 
70 class Action {
71 protected:
73  float _duration;
74 
75 #pragma mark -
76 #pragma mark Constructors
77 public:
84  Action() {}
85 
89  ~Action() {}
90 
91 #pragma mark -
92 #pragma mark Attributes
93 
100  float getDuration() const { return _duration; }
101 
109  void setDuration(float time) { _duration = time; }
110 
111 #pragma mark -
112 #pragma mark Animation Methods
113 
118  virtual std::shared_ptr<Action> clone();
119 
129  virtual void load(const std::shared_ptr<Node>& target, Uint64* state) {}
130 
141  virtual void update(const std::shared_ptr<Node>& target, Uint64* state, float dt) {}
142 
143 
144 #pragma mark -
145 #pragma mark Debugging Methods
146 
156  virtual std::string toString(bool verbose = false) const;
157 
159  operator std::string() const { return toString(); }
160 };
161 
162 }
163 #endif /* __CU_ACTION_H__ */
cugl::Action
Definition: CUAction.h:70
cugl::Action::update
virtual void update(const std::shared_ptr< Node > &target, Uint64 *state, float dt)
Definition: CUAction.h:141
cugl::Action::load
virtual void load(const std::shared_ptr< Node > &target, Uint64 *state)
Definition: CUAction.h:129
cugl::Action::Action
Action()
Definition: CUAction.h:84
cugl::Action::clone
virtual std::shared_ptr< Action > clone()
cugl::Action::setDuration
void setDuration(float time)
Definition: CUAction.h:109
cugl::Action::_duration
float _duration
Definition: CUAction.h:73
cugl::Action::getDuration
float getDuration() const
Definition: CUAction.h:100
cugl::Action::~Action
~Action()
Definition: CUAction.h:89
cugl::Action::toString
virtual std::string toString(bool verbose=false) const