1 /* 2 Copyright © 2012 Stefan Beller 3 Copyright © 2014 Henrik Andersson 4 Copyright © 2013-2016 Justin Jacobs 5 6 This file is part of FLARE. 7 8 FLARE is free software: you can redistribute it and/or modify it under the terms 9 of the GNU General Public License as published by the Free Software Foundation, 10 either version 3 of the License, or (at your option) any later version. 11 12 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License along with 17 FLARE. If not, see http://www.gnu.org/licenses/ 18 */ 19 20 #ifndef ANIMATION_SET_H 21 #define ANIMATION_SET_H 22 23 #include "CommonIncludes.h" 24 #include "AnimationMedia.h" 25 26 class Animation; 27 28 /** 29 * The animation set contains all animations of one entity, hence it 30 * they are all using the same spritesheet. 31 * 32 * The animation set is responsible for the spritesheet to be freed. 33 */ 34 class AnimationSet { 35 private: 36 const std::string name; //i.e. animations/goblin_runner.txt, matches the animations filename. 37 std::string imagefile; 38 Animation *defaultAnimation; // has always a non-null animation, in case of successfull load it contains the first animation in the animation file. 39 bool loaded; 40 AnimationSet *parent; 41 42 void load(); 43 unsigned getAnimationFrames(const std::string &_name); 44 45 public: 46 47 std::vector<Animation*> animations; 48 49 AnimationMedia *sprite; 50 51 explicit AnimationSet(const std::string &animationname); 52 AnimationSet(const AnimationSet &a); // copy constructor not implemented. 53 ~AnimationSet(); 54 55 /** 56 * callee is responsible to free the returned animation. 57 * Returns the animation specified by \a name. If that animation is not found 58 * a default animation is returned. 59 */ 60 Animation *getAnimation(const std::string &name); 61 getName()62 const std::string &getName() { 63 return name; 64 } 65 setParent(AnimationSet * other)66 void setParent(AnimationSet *other) { 67 parent = other; 68 } 69 }; 70 71 #endif // __ANIMATION_SET__ 72