/
Animation.cpp
74 lines (56 loc) · 1.48 KB
/
Animation.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
68
69
70
71
72
73
74
/*
* GDevelop Core
* Copyright 2008-2014 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
#include "GDCore/BuiltinExtensions/SpriteExtension/Animation.h"
#include "GDCore/BuiltinExtensions/SpriteExtension/Direction.h"
#include "GDCore/BuiltinExtensions/SpriteExtension/Sprite.h"
#include <string>
#include <vector>
namespace gd {
Direction Animation::badDirection;
Animation::Animation() :
useMultipleDirections(false)
{
}
Animation::~Animation()
{
}
unsigned int Animation::GetDirectionsCount() const
{
return directions.size();
};
bool Animation::HasNoDirections() const
{
return directions.empty();
};
void Animation::SetDirectionsCount(unsigned int nb)
{
while ( directions.size() < nb ) {
Direction direction;
directions.push_back(direction);
}
while ( directions.size() > nb )
directions.erase(directions.begin()+directions.size()-1);
}
const Direction & Animation::GetDirection(unsigned int nb) const
{
if (!useMultipleDirections) nb = 0;
if ( nb < directions.size() )
return directions[nb];
return badDirection;
}
Direction & Animation::GetDirection(unsigned int nb)
{
if (!useMultipleDirections) nb = 0;
if (nb < directions.size() )
return directions[nb];
return badDirection;
}
void Animation::SetDirection(const Direction & direction, unsigned int nb)
{
if (nb < directions.size() ) directions[nb] = direction;
return;
}
}