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)
33 SimpleAnimation::SimpleAnimation(loader::noinit_t n)
39 int SimpleAnimation::NumFrames() const {
43 int SimpleAnimation::Col(int frame) const {
47 int SimpleAnimation::Row(int frame) const {
52 void SimpleAnimation::CreateTypeDescription() {
56 TypeDescription &td(TypeDescription::Create(TYPE_ID, "SimpleAnimation"));
57 td.SetDescription("An animation that uses a fixed column and increasing row of a sprite based on the frame number.");
58 td.SetConstructor(&Construct);
59 td.SetInitializer(&Initialize);
60 td.SetSize(sizeof(SimpleAnimation));
61 td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&sa));
63 Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa));
64 td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("number of frames of a single run"));
65 td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the column of the sprite to draw from"));
66 td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the row of the sprite of the first frame"));
69 void SimpleAnimation::Construct(void *data) {
70 new (data) SimpleAnimation;
73 void SimpleAnimation::Initialize(void *data) {
74 new (data) SimpleAnimation(loader::noinit);