Polyphase Game Engine
Loading...
Searching...
No Matches
TweenManager.h
Go to the documentation of this file.
1#pragma once
2
3#include "PolyphaseAPI.h"
4#include "EngineTypes.h"
5#include "ScriptFunc.h"
6#include "Easing.h"
7
8#include <glm/glm.hpp>
9#include <vector>
10
11enum class TweenTarget : uint8_t
12{
13 None,
16 Scale,
17 Color
18};
19
21{
22 int32_t id = 0;
24 glm::vec4 startVal = glm::vec4(0.0f);
25 glm::vec4 endVal = glm::vec4(0.0f);
26 float duration = 1.0f;
27 float elapsed = 0.0f;
28 bool paused = false;
29 bool finished = false;
30 bool isScalar = false;
31 uint8_t components = 4; // 1 for scalar, 3 for vec3, 4 for vec4/color/quat
34 Node* targetNode = nullptr;
36};
37
39{
40public:
41 static TweenManager* Get();
42 static void Create();
43 static void Destroy();
44
45 void Update(float deltaTime);
46
47 int32_t CreateTween(const TweenData& data);
48 void CancelTween(int32_t id);
49 void CancelAllTweens();
50 void PauseTween(int32_t id);
51 void ResumeTween(int32_t id);
52
53private:
54 TweenData* FindTween(int32_t id);
55 void ApplyToNode(TweenData& tween, const glm::vec4& value);
56
57 std::vector<TweenData> mTweens;
58 int32_t mNextId = 1;
59
60 static TweenManager* sInstance;
61};
62
easing_functions
Definition Easing.h:4
@ EaseLinear
Definition Easing.h:5
bool Update()
Definition Engine.cpp:710
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
TweenTarget
Definition TweenManager.h:12
TweenManager * GetTweenManager()
Definition TweenManager.cpp:32
Definition Node.h:67
Definition ScriptFunc.h:10
Definition TweenManager.h:39
Definition TweenManager.h:21
float duration
Definition TweenManager.h:26
uint8_t components
Definition TweenManager.h:31
ScriptFunc onUpdate
Definition TweenManager.h:32
float elapsed
Definition TweenManager.h:27
glm::vec4 endVal
Definition TweenManager.h:25
easing_functions easingType
Definition TweenManager.h:23
ScriptFunc onComplete
Definition TweenManager.h:33
bool isScalar
Definition TweenManager.h:30
bool finished
Definition TweenManager.h:29
glm::vec4 startVal
Definition TweenManager.h:24
Node * targetNode
Definition TweenManager.h:34
bool paused
Definition TweenManager.h:28
TweenTarget target
Definition TweenManager.h:35