1 #include "AnimationFactory.h"
2 #include <iostream>
3
4 using namespace std;
5
AnimationFactory()6 AnimationFactory::AnimationFactory(){
7 };
8
~AnimationFactory()9 AnimationFactory::~AnimationFactory(){
10 unsigned int i;
11 for(i=0; i<store.size(); i++){
12 Animation* tmp = (Animation*)(store[i]);
13 //cout << "Deleting Animation" << i << "\n";
14 delete tmp;
15 }
16 };
17
list()18 void AnimationFactory::list(){
19 unsigned int i;
20 for(i=0; i<store.size(); i++){
21 printf("> %s\n",((Animation*)store[i])->getKnown());
22 }
23 };
24
getLast()25 Animation* AnimationFactory::getLast(){
26 return (Animation*)store[store.size()-1];
27 };
28
getByNumber(unsigned int n)29 Animation* AnimationFactory::getByNumber(unsigned int n){
30 if(n<store.size() && n>=0){
31 return (Animation*)store[n];
32 } else {
33 return NULL;
34 }
35 };
36
size()37 int AnimationFactory::size(){
38 return store.size();
39 };
40
getByName(const char * name)41 Animation* AnimationFactory::getByName(const char* name){
42 //printf("Getting %s by name from store of %d items\n",name,store.size());
43 unsigned int i;
44 for(i=0; i<store.size(); i++){
45 //printf("Item %d is %s\n",i,((Animation*)store[i])->getKnown());
46 Animation* tmp = ((Animation*)(store[i]));
47 //printf("Comparing %s with %s\n",tmp->getKnown(), name);
48 if(strcmp(tmp->getKnown(), name) == 0){
49 //printf("Match Found\n");
50 return tmp;
51 }
52 }
53 return NULL;
54 };
55
loadAnimation(char * spriteName,char * path,bool loop,char * knownAs)56 void AnimationFactory::loadAnimation(char* spriteName, char* path, bool loop, char* knownAs){
57 Animation* a = new Animation(spriteName, path, loop, knownAs);
58 store.push_back(a);
59 //printf("Added. Store now stands at %d item\n",store.size());
60 };
61