--- /dev/null
+/*
+ * ComplexAnimation.cpp
+ *
+ * Created on: Sep 5, 2012
+ * Author: holy
+ */
+
+#include "ComplexAnimation.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace graphics {
+
+void ComplexAnimation::CreateTypeDescription() {
+ ComplexAnimation ca;
+ Animation *a(&ca);
+ TypeDescription &td(TypeDescription::CreateOrGet("ComplexAnimation"));
+
+ td.SetSize(sizeof(ComplexAnimation));
+ td.AddSupertype(TypeDescription::GetTypeId("Animation"), ((char *)a) - ((char *)&ca));
+
+ int frameId(TypeDescription::GetTypeId("ComplexAnimationFrame"));
+
+ td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), frameId, true, true));
+
+
+ FrameProp fp;
+ TypeDescription &ftd(TypeDescription::CreateOrGet("ComplexAnimationFrame"));
+
+ ftd.SetSize(sizeof(FrameProp));
+
+ int numberId(TypeDescription::GetTypeId("Number"));
+ int vectorId(TypeDescription::GetTypeId("Vector"));
+
+ ftd.AddField("column", FieldDescription(((char *)&fp.col) - ((char *)&fp), numberId, false));
+ ftd.AddField("row", FieldDescription(((char *)&fp.row) - ((char *)&fp), numberId, false));
+ ftd.AddField("disposition", FieldDescription(((char *)&fp.disposition) - ((char *)&fp), vectorId, false));
+}
+
+}
#include "Animation.h"
-#include <vector>
-
namespace graphics {
class ComplexAnimation
: public Animation {
public:
- ComplexAnimation() { }
+ ComplexAnimation() : frames(0), numFrames(0) { }
ComplexAnimation(const Sprite *sprite, int frameTime, bool repeat = false)
- : Animation(sprite, frameTime, repeat) { }
-
-public:
- void AddFrame(int col, int row, const geometry::Vector<int> &disposition = geometry::Vector<int>()) {
- frames.push_back(FrameProp(col, row, disposition));
- }
- void AddFrames(int col, int row, const geometry::Vector<int> &disposition, int amount) {
- for (int i(0); i < amount; ++i) {
- AddFrame(col, row, disposition);
- }
- }
+ : Animation(sprite, frameTime, repeat), frames(0), numFrames(0) { }
public:
struct FrameProp {
int row;
geometry::Vector<int> disposition;
};
- void AddFrame(const FrameProp &f) { frames.push_back(f); }
+ void SetFrames(const FrameProp *f, int num) { frames = f; numFrames = num; }
+
+ static void CreateTypeDescription();
protected:
- virtual int NumFrames() const { return frames.size(); };
+ virtual int NumFrames() const { return numFrames; };
virtual int Col(int frame) const { return frames[frame].col; }
virtual int Row(int frame) const { return frames[frame].row; }
virtual geometry::Vector<int> Offset(int frame) const { return frames[frame].disposition; }
private:
- std::vector<FrameProp> frames;
+ const FrameProp *frames;
+ int numFrames;
};