]> git.localhorst.tv Git - l2e.git/blob - src/graphics/SimpleAnimation.cpp
baed3419188b2f393e0e27ade3d3b56f7e38f0f3
[l2e.git] / src / graphics / SimpleAnimation.cpp
1 #include "SimpleAnimation.h"
2
3 #include "../loader/Interpreter.h"
4 #include "../loader/TypeDescription.h"
5
6 using loader::FieldDescription;
7 using loader::Interpreter;
8 using loader::TypeDescription;
9
10 namespace graphics {
11
12 void SimpleAnimation::CreateTypeDescription() {
13         SimpleAnimation sa;
14         Animation *a(&sa);
15
16         TypeDescription &td(TypeDescription::Create(TYPE_ID, "SimpleAnimation"));
17         td.SetDescription("An animation that uses a fixed column and increasing row of a sprite based on the frame number.");
18         td.SetConstructor(&Construct);
19         td.SetSize(sizeof(SimpleAnimation));
20         td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&sa));
21
22         Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa));
23         td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("number of frames of a single run"));
24         td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the column of the sprite to draw from"));
25         td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the row of the sprite of the first frame"));
26 }
27
28 void SimpleAnimation::Construct(void *data) {
29         new (data) SimpleAnimation;
30 }
31
32 }