Repository navigation
Expand file tree
/
Copy pathspritepop.cpp
More file actions
114 lines (93 loc) · 2.55 KB
/
Copy pathspritepop.cpp
File metadata and controls
114 lines (93 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "spritepop.h"
#include "app.h"
SpritePop::SpritePop(const char *sprite, u32 ms, f32 x, f32 y, bool pulse)
: sptPop()
, movPop()
, tlPop()
, kfPop()
{
sptPop.Load(sprite);
sptPop.SetPriority(100000);
sptPop.SetBlending(BlendModulateAlpha);
//pScene->Add(&sptPop);
u32 targetFrames = 30 * ms / 1000;
if (pulse)
{
kfPop[0].bTween = TRUE;
kfPop[0].iColorA = 0;
kfPop[0].fEasing = 1.f;
kfPop[1].bTween = TRUE;
kfPop[1].iColorA = 255;
kfPop[1].fEasing = -1.f;
kfPop[2].bTween = TRUE;
kfPop[2].iColorA = 0;
kfPop[2].iEvent = Keyframe::KEYFRAME_EVENT_JUMPTOFRAME;
kfPop[2].iFrameToJump = 0;
kfPop[2].fEasing = 1.f;
kfPop[3].pstrName = "hiding";
kfPop[3].bTween = TRUE;
kfPop[3].iColorA = 255;
kfPop[4].bTween = TRUE;
kfPop[4].iColorA = 0;
kfPop[4].iEvent = Keyframe::KEYFRAME_EVENT_STOP;
tlPop.AddKeyframe(0, &kfPop[0]);
tlPop.AddKeyframe(targetFrames / 2.f, &kfPop[1]);
tlPop.AddKeyframe(targetFrames, &kfPop[2]);
tlPop.AddKeyframe(targetFrames + 1 + static_cast<f32>(targetFrames) * .1f, &kfPop[3]);
tlPop.AddKeyframe(targetFrames + 1 + static_cast<f32>(targetFrames) * .1f + 10, &kfPop[4]);
tlPop.SetObject(&sptPop);
}
else
{
kfPop[0].bTween = TRUE;
kfPop[0].iColorA = 0;
kfPop[1].bTween = TRUE;
kfPop[1].iColorA = 255;
kfPop[1].iEvent = Keyframe::KEYFRAME_EVENT_STOP;
kfPop[2].pstrName = "hiding";
kfPop[2].bTween = TRUE;
kfPop[2].iColorA = 255;
kfPop[3].bTween = TRUE;
kfPop[3].iColorA = 0;
kfPop[3].iEvent = Keyframe::KEYFRAME_EVENT_STOP;
tlPop.AddKeyframe(0, &kfPop[0]);
tlPop.AddKeyframe(targetFrames, &kfPop[1]);
tlPop.AddKeyframe(targetFrames + 1, &kfPop[2]);
tlPop.AddKeyframe(targetFrames + 1 + static_cast<f32>(targetFrames) * .5f, &kfPop[3]);
tlPop.SetObject(&sptPop);
// tlPop.SetListener(this);
}
movPop.AddTimeline(&tlPop);
SetPosition(x, y);
pScene->Add(&movPop);
}
SpritePop::~SpritePop()
{
pScene->Remove(&movPop);
}
void SpritePop::Show()
{
//movPop.SetVisible(TRUE);
tlPop.GotoAndPlay(static_cast<u32>(0));
}
void SpritePop::Hide()
{
movPop.SetVisible(FALSE);
if (tlPop.GetCurrentKeyframe() == &kfPop[0] || tlPop.GetCurrentKeyframe() == &kfPop[1])
tlPop.GotoAndPlay("hiding");
}
bool SpritePop::IsVisible() const
{
return tlPop.GetCurrentKeyframe() != &kfPop[3] && tlPop.GetCurrentKeyframe() != &kfPop[4];
}
void SpritePop::SetPosition(f32 x, f32 y)
{
movPop.SetPosition(x - sptPop.GetWidth() / 2.f, y - sptPop.GetHeight() / 2.f);
}
void SpritePop::AddPosition(f32 x, f32 y)
{
movPop.AddPosition(x, y);
}
void SpritePop::OnTimelineFrame(const EventMovie *ev)
{
}