--- /dev/null
+/*
+ * Animation.cpp
+ *
+ * Created on: Sep 5, 2012
+ * Author: holy
+ */
+
+#include "Animation.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace graphics {
+
+void AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset) {
+ int boolId(TypeDescription::GetTypeId("Boolean"));
+ int numberId(TypeDescription::GetTypeId("Number"));
+ int spriteId(TypeDescription::GetTypeId("Sprite"));
+
+ td.AddField("sprite", FieldDescription(((char *)&a.sprite) - ((char *)&a) - offset, spriteId, true));
+ td.AddField("frametime", FieldDescription(((char *)&a.frameTime) - ((char *)&a) - offset, numberId, false));
+ td.AddField("repeat", FieldDescription(((char *)&a.repeat) - ((char *)&a) - offset, boolId, false));
+}
+
+}
#include "../app/Timer.h"
#include "../geometry/Vector.h"
+#include <memory>
#include <SDL.h>
+namespace loader {
+ class TypeDescription;
+}
+
namespace graphics {
class Animation {
virtual int Row(int frame) const = 0;
virtual geometry::Vector<int> Offset(int frame) const { return geometry::Vector<int>(); }
+protected:
+ static void AddFields(loader::TypeDescription &, const Animation &, std::ptrdiff_t offset);
+
private:
const Sprite *sprite;
int frameTime;
--- /dev/null
+/*
+ * SimpleAnimation.cpp
+ *
+ * Created on: Sep 5, 2012
+ * Author: holy
+ */
+
+#include "SimpleAnimation.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace graphics {
+
+void SimpleAnimation::CreateTypeDescription() {
+ SimpleAnimation sa;
+ Animation *a(&sa);
+ TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation"));
+
+ td.SetSize(sizeof(SimpleAnimation));
+ td.AddSupertype(TypeDescription::GetTypeId("Animation"), ((char *)a) - ((char *)&sa));
+
+ int numberId(TypeDescription::GetTypeId("Number"));
+
+ td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId, false));
+ td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId, false));
+ td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId, false));
+}
+
+}
void SetCol(int c) { col = c; }
void SetRow(int r) { row = r; }
+ static void CreateTypeDescription();
+
protected:
virtual int NumFrames() const { return numFrames; };
virtual int Col(int frame) const { return col; }