TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
tb_sprite_sheet.h
1 
9 #ifndef _TurtleBrains_SpriteSheet_h_
10 #define _TurtleBrains_SpriteSheet_h_
11 
12 #include "tb_sprite.h" //for SpriteFrame
13 #include "tb_animated_sprite.h" //for AnimationSequence
14 #include "tb_texture_manager.h"
15 #include "../core/tb_string.h"
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 = kInvalidTexture);
43 
50  void AddSpriteFrame(const tbCore::tbString& spriteName, const SpriteFrame& spriteFrame);
51 
56  const SpriteFrame& GetSpriteFrame(const tbCore::tbString& spriteName) const;
57 
61  void AddAnimationSequence(const tbCore::tbString& animationName, const AnimationSequence& animationSequence);
62 
66  void AddAnimationSequence(const tbCore::tbString& spriteName, const tbCore::tbString& animationName, const AnimationSequence& animationSequence);
67 
72  const AnimationSequence& GetAnimationSequence(const tbCore::tbString& animationName) const;
73 
78  const AnimationSequence& GetAnimationSequence(const tbCore::tbString& spriteName, const tbCore::tbString& animationName) const;
79 
84  bool AddGlobalAnimationSequencesToSprite(const tbCore::tbString& spriteName, const std::vector<tbCore::tbString>& animationNames);
85 
89  //bool HasAnimationsForSprite(const tbCore::tbString& spriteName) const;
90 
95  const AnimationSequenceContainer& GetAnimationSequencesForSprite(const tbCore::tbString& spriteName) const;
96 
101  void SetTextureHandle(const TextureHandle& textureHandle);
102 
106  const TextureHandle& GetTextureHandle(void) const;
107 
108  private:
109  typedef std::map<tbCore::tbString, SpriteFrame> SpriteFrameContainer;
110  typedef std::map<tbCore::tbString, AnimationSequenceContainer> SpriteAnimationSequences;
111 
112  //Global Animation Sequences
113  //explode, spawn
114 
115  //Sprite Animation Sequences
116  //bunny1, idle, jump, eat, 'explode'
117  //bunny2, idle, jump, eat, 'spawn'
118 
119  SpriteFrameContainer mSpriteFrames;
120  AnimationSequenceContainer mGlobalAnimationSequences; //Global Animations //animationName / sequenceData
121  SpriteAnimationSequences mSpriteAnimationSequences; //Sprite Animations //spriteName, has a table of: animationName / sequenceData
122  tbCore::tbString mSpriteSheetName;
123  TextureHandle mTextureHandle;
124  };
125 
126  }; /* namespace Graphics */
127 }; /* namespace TurtleBrains */
128 
130 
131 #endif /* _TurtleBrains_SpriteSheet_h_ */
const AnimationSequenceContainer & GetAnimationSequencesForSprite(const tbCore::tbString &spriteName) const
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
SpriteSheet(const TextureHandle &textureHandle=kInvalidTexture)
const SpriteFrame & GetSpriteFrame(const tbCore::tbString &spriteName) const
Definition: tb_sprite.h:29
void AddAnimationSequence(const tbCore::tbString &animationName, const AnimationSequence &animationSequence)
const TextureHandle & GetTextureHandle(void) const
void AddSpriteFrame(const tbCore::tbString &spriteName, const SpriteFrame &spriteFrame)
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
const AnimationSequence & GetAnimationSequence(const tbCore::tbString &animationName) const
Definition: tb_animated_sprite.h:29
tbCore::uint32 TextureHandle
Definition: tb_texture_manager.h:43
const TextureHandle kInvalidTexture
Definition: tb_sprite_sheet.h:33
void SetTextureHandle(const TextureHandle &textureHandle)
std::string tbString
Definition: tb_string.h:335
bool AddGlobalAnimationSequencesToSprite(const tbCore::tbString &spriteName, const std::vector< tbCore::tbString > &animationNames)