-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsprite.cpp
67 lines (56 loc) · 1.18 KB
/
sprite.cpp
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
#include "sprite.h"
void Sprite::pause() {
paused = true;
ssPlayer->animePause();
}
void Sprite::unpause() {
paused = false;
ssPlayer->animeResume();
}
void Sprite::replay()
{
ssPlayer->play(animation_list[anim_index], 1);
ssPlayer->setStep(play_speed);
}
void Sprite::next_anim()
{
anim_index = (anim_index == 0) ? animation_list.size() - 1 : --anim_index;
ssPlayer->play(animation_list[anim_index], !looping);
ssPlayer->setStep(play_speed);
unpause();
}
void Sprite::previous_anim()
{
anim_index = (anim_index == animation_list.size() - 1) ? 0 : ++anim_index;
ssPlayer->play(animation_list[anim_index], !looping);
ssPlayer->setStep(play_speed);
unpause();
}
bool Sprite::is_looping() const
{
return looping;
}
bool Sprite::is_paused() const
{
return paused;
}
float Sprite::get_play_speed() const
{
return play_speed;
}
void Sprite::set_play_speed(float speed)
{
play_speed = speed;
ssPlayer->setStep(play_speed);
}
std::string Sprite::get_anim_name() const
{
return ssPlayer->getPlayAnimeName();
}
void Sprite::toggle_looping()
{
ssPlayer->play(animation_list[anim_index], looping, ssPlayer->getFrameNo());
ssPlayer->setStep(play_speed);
looping = !looping;
unpause();
}