2 #include "oxygine-include.h" 3 #include "core/Object.h" 4 #include "closure/closure.h" 5 #include "utils/intrusive_list.h" 6 #include "UpdateState.h" 8 #include "EventDispatcher.h" 21 DONE = Event::COMPLETE,
25 Actor* getActor()
const;
33 const int TWEEN_COMPLETE_DT = std::numeric_limits<int>::max() / 2;
36 DECLARE_SMART(
Tween, spTween);
97 void init(timeMS duration,
int loops = 1,
bool twoSides =
false, timeMS delay = 0, EASE ease = Tween::ease_linear);
102 int getLoops()
const {
return _loops; }
103 timeMS getDuration()
const {
return _duration; }
104 timeMS getElapsed()
const {
return _elapsed; }
105 EASE getEase()
const {
return _ease; }
106 EASE getGlobalEase()
const {
return _globalEase; }
107 timeMS getDelay()
const {
return _delay; }
108 Actor* getClient()
const {
return _client; }
109 float getPercent()
const {
return _percent; }
110 spObject getDataObject()
const {
return _data; }
111 spTween getNextSibling() {
return intr_list::getNextSibling(); }
112 spTween getPrevSibling() {
return intr_list::getPrevSibling(); }
113 const EventCallback& getDoneCallback()
const {
return _cbDone; }
115 bool isStarted()
const {
return _status != status_not_started; }
116 bool isDone()
const {
return _status == status_remove; }
132 void setDuration(timeMS duration) { _duration = duration; }
133 void setClient(Actor* client) { _client = client; }
134 void setTwoSides(
bool ts) { _twoSides = ts; }
140 virtual void complete(timeMS deltaTime = TWEEN_COMPLETE_DT);
145 void start(
Actor& actor);
148 static float calcEase(EASE ease,
float v);
149 typedef float (*easeHandler)(EASE ease,
float v);
150 static void setCustomEaseHandler(easeHandler);
158 virtual void _start(
Actor& actor) {}
159 virtual void _update(Actor& actor,
const UpdateState& us) {}
160 virtual void _done(Actor& actor,
const UpdateState& us) {}
161 virtual void _loopDone(Actor& actor,
const UpdateState& us) {}
162 virtual float _calcEase(
float v);
186 EventCallback _cbDone;
196 typedef typename GS::type type;
198 TweenT(
const GS& gs) : _gs(gs) {}
202 type& t = *safeCast<type*>(&actor);
203 _gs.update(t, _percent, us);
206 void _start(
Actor& actor)
208 type& t = *safeCast<type*>(&actor);
212 _gs.update(t, _calcEase(0.0f), us);
217 type& t = *safeCast<type*>(&actor);
221 GS& getGS() {
return _gs; }
228 template <
typename GS>
229 TweenT<GS>* createTween(
const GS& gs, timeMS duration,
int loops = 1,
bool twoSides =
false, timeMS delay = 0, Tween::EASE ease = Tween::ease_linear)
232 p->init(duration, loops, twoSides, delay, ease);
236 template <
typename GS>
237 TweenT<GS>* createTween2(
const GS& gs,
const TweenOptions& opt)
239 TweenT<GS>* p =
new TweenT<GS>(gs);
244 std::string ease2String(Tween::EASE ease);
251 DECLARE_SMART(TweenObj, spTweenObj);
257 virtual void init(
Actor&) {}
258 virtual void done(
Actor&) {}
269 void init(
Actor& a) { _obj->init(a); }
270 void done(
Actor& a) { _obj->done(a); }
271 void update(
Actor& a,
float p,
const UpdateState& us) { _obj->update(a, p, us); }
void detachWhenDone(bool detach=true)
Definition: Tween.h:137
void setDoneCallback(const EventCallback &cb)
void addDoneCallback(const EventCallback &cb)
Definition: intrusive_list.h:183
void setGlobalEase(EASE ease)
Definition: Tween.h:126
void setLoops(int loops)
Definition: Tween.h:130
void setDelay(timeMS delay)
Definition: Tween.h:128
Definition: UpdateState.h:6
virtual void complete(timeMS deltaTime=TWEEN_COMPLETE_DT)
–oxgl-end–!
Definition: Actor.h:14
int iteration
Definition: UpdateState.h:18
void setEase(EASE ease)
Definition: Tween.h:124
void setDataObject(spObject data)
Definition: Tween.h:119
Definition: EventDispatcher.h:27