TDME2  1.9.200
GUIPositionEffect.cpp
Go to the documentation of this file.
2 
3 #include <tdme/tdme.h>
7 #include <tdme/gui/GUI.h>
8 #include <tdme/math/Math.h>
9 
11 
15 using tdme::gui::GUI;
16 using tdme::math::Math;
17 
18 GUIPositionEffect::GUIPositionEffect(GUINode* guiNode): GUIEffect(EFFECTTYPE_POSITION, guiNode)
19 {
20 }
21 
23 {
24  float screenWidth = guiRenderer->getGUI()->getWidth();
25  float screenHeight = guiRenderer->getGUI()->getHeight();
26  auto t = Math::abs(timeTotal) < Math::EPSILON?1.0f:(timeTotal - timeLeft) / timeTotal;
27  auto effectState = node->getEffectState();
29  effectState->positionY = startState.positionY + ((endState.positionY - startState.positionY) * t);
30  guiRenderer->setGUIEffectOffsetX(guiRenderer->getGUIEffectOffsetX() + -effectState->positionX / screenWidth * 2.0f);
31  guiRenderer->setGUIEffectOffsetY(guiRenderer->getGUIEffectOffsetY() + -effectState->positionY / screenHeight * 2.0f);
32 }
GUI module class.
Definition: GUI.h:64
int getHeight()
Definition: GUI.h:182
int getWidth()
Definition: GUI.h:175
GUI effect base class.
Definition: GUIEffect.h:26
GUIEffectState startState
Definition: GUIEffect.h:47
void apply(GUIRenderer *guiRenderer) override
Apply effect.
GUI node base class.
Definition: GUINode.h:64
GUIEffectState * getEffectState()
Definition: GUINode.h:722
void setGUIEffectOffsetY(float guiEffectOffsetY)
Set GUI effect offset Y.
void setGUIEffectOffsetX(float guiEffectOffsetX)
Set GUI effect offset X.
Standard math functions.
Definition: Math.h:19