TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_sprite_sheet.hpp
1 
9 #ifndef TurtleBrains_SpriteSheet_hpp
10 #define TurtleBrains_SpriteSheet_hpp
11 
12 #include <turtle_brains/graphics/tb_sprite.hpp> //for SpriteFrame
13 #include <turtle_brains/graphics/tb_animated_sprite.hpp> //for AnimationSequence
14 #include <turtle_brains/graphics/tb_texture_manager.hpp>
15 #include <turtle_brains/core/tb_string.hpp>
16 
17 #include <map>
18 
19 namespace TurtleBrains
20 {
21  namespace Graphics
22  {
23 
34  {
35  public:
36  typedef std::map<tbCore::tbString, AnimationSequence> AnimationSequenceContainer;
37 
42  explicit SpriteSheet(const TextureHandle& textureHandle = InvalidTexture());
43 
50  void AddSpriteFrame(const tbCore::tbString& spriteName, const SpriteFrame& spriteFrame);
51 
56  const SpriteFrame& GetSpriteFrame(const tbCore::tbString& spriteName) const;
57 
64  void AddAnimationSequence(const tbCore::tbString& spriteName, const tbCore::tbString& animationName, const AnimationSequence& animationSequence);
65 
70  const AnimationSequence& GetAnimationSequence(const tbCore::tbString& animationName) const;
71 
76  const AnimationSequence& GetAnimationSequence(const tbCore::tbString& spriteName, const tbCore::tbString& animationName) const;
77 
82  bool AddGlobalAnimationSequencesToSprite(const tbCore::tbString& spriteName, const std::vector<tbCore::tbString>& animationNames);
83 
87  //bool HasAnimationsForSprite(const tbCore::tbString& spriteName) const;
88 
93  const AnimationSequenceContainer& GetAnimationSequencesForSprite(const tbCore::tbString& spriteName) const;
94 
99  void SetTextureHandle(const TextureHandle& textureHandle);
100 
104  const TextureHandle& GetTextureHandle(void) const;
105 
106  private:
107  typedef std::map<tbCore::tbString, SpriteFrame> SpriteFrameContainer;
108  typedef std::map<tbCore::tbString, AnimationSequenceContainer> SpriteAnimationSequences;
109 
110  //Global Animation Sequences
111  //explode, spawn
112 
113  //Sprite Animation Sequences
114  //bunny1, idle, jump, eat, 'explode'
115  //bunny2, idle, jump, eat, 'spawn'
116 
117  SpriteFrameContainer mSpriteFrames;
118  AnimationSequenceContainer mGlobalAnimationSequences; //Global Animations //animationName / sequenceData
119  SpriteAnimationSequences mSpriteAnimationSequences; //Sprite Animations //spriteName, has a table of: animationName / sequenceData
120  tbCore::tbString mSpriteSheetName;
121  TextureHandle mTextureHandle;
122  };
123 
124  }; /* namespace Graphics */
125 }; /* namespace TurtleBrains */
126 
128 
129 #endif /* TurtleBrains_SpriteSheet_hpp */
const AnimationSequenceContainer & GetAnimationSequencesForSprite(const tbCore::tbString &spriteName) const
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
const SpriteFrame & GetSpriteFrame(const tbCore::tbString &spriteName) const
Definition: tb_sprite.hpp:29
const TextureHandle & GetTextureHandle(void) const
void AddAnimationSequence(const tbCore::tbString &spriteName, const tbCore::tbString &animationName, const AnimationSequence &animationSequence)
void AddSpriteFrame(const tbCore::tbString &spriteName, const SpriteFrame &spriteFrame)
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
const AnimationSequence & GetAnimationSequence(const tbCore::tbString &animationName) const
TextureHandle InvalidTexture(void)
Definition: tb_animated_sprite.hpp:29
Definition: tb_sprite_sheet.hpp:33
void SetTextureHandle(const TextureHandle &textureHandle)
SpriteSheet(const TextureHandle &textureHandle=InvalidTexture())
std::string tbString
Definition: tb_string.hpp:335
bool AddGlobalAnimationSequencesToSprite(const tbCore::tbString &spriteName, const std::vector< tbCore::tbString > &animationNames)