-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathObjectAnimation.h
More file actions
82 lines (68 loc) · 3.75 KB
/
Copy pathObjectAnimation.h
File metadata and controls
82 lines (68 loc) · 3.75 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
private:
class ObjectAnimation : public std::enable_shared_from_this<ObjectAnimation>
{
public:
std::string Name; //имя анимации
//класс спрайта
public:
class Sprite : public std::enable_shared_from_this<Sprite>
{
public:
std::string Name; //имя спрайта
std::int32_t Type = 0; //тип спрайта
std::int32_t Width = 0; //ширина спрайта
std::int32_t Height = 0; //высота спрайта
std::int32_t **ClassicLayer; //слой для классического режима
SdlDotNetCompat::Drawing::Color **NextLayer; //слой для режима Next
};
public:
std::vector<std::shared_ptr<Sprite>> Sprites = std::vector<std::shared_ptr<Sprite>>(); //список спрайтов
//класс элемента композиции
public:
class CompositionElement : public std::enable_shared_from_this<CompositionElement>
{
public:
std::shared_ptr<Sprite> ElemSprite; //спрайт элемента композиции
std::int32_t XOffset = 0; //смещение спрайта по X
std::int32_t YOffset = 0; //смещение спрайта по Y
};
//класс кадра
public:
class Frame : public std::enable_shared_from_this<Frame>
{
public:
std::vector<std::shared_ptr<CompositionElement>> Composition; //список элементов в композиции
std::int32_t Time = 0; //время проигрывания кадра во фреймах
std::int32_t DX1 = 0, DY1 = 0, DX2 = 0, DY2 = 0; //коллайдер повреждения
std::int32_t HX1 = 0, HY1 = 0, HX2 = 0, HY2 = 0; //коллайдер удара
std::string Event; //название события
};
//класс анимации
public:
class Animation : public std::enable_shared_from_this<Animation>
{
public:
std::string Name; //имя анимации
std::vector<std::shared_ptr<Frame>> Frames; //список кадров
bool Loop = false; //анимация зациклена
};
public:
std::vector<std::shared_ptr<Animation>> Animations = std::vector<std::shared_ptr<Animation>>(); //список анимаций
};
private:
std::vector<std::shared_ptr<ObjectAnimation>> ObjectAnimations = std::vector<std::shared_ptr<ObjectAnimation>>(); //наборы анимаций объектов
//загрузка анимаций по имени
void LoadAnimations(const std::string &name);
//загрузка проекта анимаций
void LoadAnimationsProject(const std::string &name);
//поиск спрайта по имени
std::shared_ptr<ObjectAnimation::Sprite> FindSprite(const std::string &name, const std::shared_ptr<ObjectAnimation> &anim);
//инициализация анимации по имени
void InitAnimation(const std::shared_ptr<GameObject> &obj, const std::string &name, bool hard_enable);
void InitAnimation(const std::shared_ptr<GameObject> &obj, std::uint8_t id_anim, bool hard_enable);
//проигрывание анимации (вызывается каждый игровой цикл)
void PlayAnimation(const std::shared_ptr<GameObject> &obj);
//высота и ширина объекта
void GetObjSize(const std::shared_ptr<Program::GameObject> &obj);
//поиск набора анимаций по имени
std::vector<std::shared_ptr<Program::ObjectAnimation>> FindObjectAnimation(const std::string &name);