1 #include "SimpleAnimation.h"
3 #include "../loader/Interpreter.h"
4 #include "../loader/TypeDescription.h"
6 using loader::FieldDescription;
7 using loader::Interpreter;
8 using loader::TypeDescription;
12 SimpleAnimation::SimpleAnimation()
19 SimpleAnimation::SimpleAnimation(
26 : Animation(sprite, frameTime, repeat)
27 , numFrames(numFrames)
34 int SimpleAnimation::NumFrames() const {
38 int SimpleAnimation::Col(int frame) const {
42 int SimpleAnimation::Row(int frame) const {
47 void SimpleAnimation::CreateTypeDescription() {
51 TypeDescription &td(TypeDescription::Create(TYPE_ID, "SimpleAnimation"));
52 td.SetDescription("An animation that uses a fixed column and increasing row of a sprite based on the frame number.");
53 td.SetConstructor(&Construct);
54 td.SetSize(sizeof(SimpleAnimation));
55 td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&sa));
57 Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa));
58 td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("number of frames of a single run"));
59 td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the column of the sprite to draw from"));
60 td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the row of the sprite of the first frame"));
63 void SimpleAnimation::Construct(void *data) {
64 new (data) SimpleAnimation;