TDME2  1.9.200
GUIEffect.cpp
Go to the documentation of this file.
2 
3 #include <tdme/tdme.h>
4 #include <tdme/engine/Engine.h>
5 #include <tdme/engine/Timing.h>
8 
14 
15 GUIEffect::GUIEffect(EffectType type, GUINode* guiNode): type(type), node(guiNode)
16 {
17 }
18 
20 }
21 
23 {
27  timePassed = 0.0f;
28  timeLast = -1LL;
30  yoyoLeft = yoyo == true?1:0;
31  active = true;
32 }
33 
35 {
36  active = false;
37 }
38 
39 bool GUIEffect::update(GUIRenderer* guiRenderer)
40 {
41  if (active == false) return false;
42  // TODO: Maybe do not use timing from main engine
43  timePassed = timeLast == -1LL?0.0f:static_cast<float>(Engine::getInstance()->getTiming()->getCurrentFrameAtTime() - timeLast) / 1000.0f;
45  timeLast = Engine::getInstance()->getTiming()->getCurrentFrameAtTime();
46  if (timeLeft < 0.0f) {
47  timeLeft = 0.0f;
48  if (yoyoLeft > 0) {
50  timePassed = 0.0f;
51  yoyoLeft--;
54  } else
55  if (repeat == -1 || repeatLeft > 0) {
57  timePassed = 0.0f;
58  if (repeat != -1) repeatLeft--;
59  yoyoLeft = yoyo == true?1:0;
62  } else
63  if (persistant == false) {
64  active = false;
65  return true;
66  }
67  }
68  return false;
69 }
70 
Engine main class.
Definition: Engine.h:131
Timing class.
Definition: Timing.h:16
GUI effect base class.
Definition: GUIEffect.h:26
GUIEffectState originalEndState
Definition: GUIEffect.h:46
virtual void start()
Start this effect.
Definition: GUIEffect.cpp:22
virtual void stop()
Stop this effect.
Definition: GUIEffect.cpp:34
GUIEffectState originalStartState
Definition: GUIEffect.h:45
virtual bool update(GUIRenderer *guiRenderer)
Updates the effect to GUI renderer and updates time.
Definition: GUIEffect.cpp:39
virtual ~GUIEffect()
Destructor.
Definition: GUIEffect.cpp:19
GUIEffectState startState
Definition: GUIEffect.h:47
GUI node base class.
Definition: GUINode.h:64
GUIEffectState * getEffectState()
Definition: GUINode.h:722
Action Interface.
Definition: Action.h:11