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