TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_sprite_manager.hpp
1 
9 #ifndef TurtleBrains_SpriteManager_hpp
10 #define TurtleBrains_SpriteManager_hpp
11 
12 #include <turtle_brains/graphics/tb_sprite.hpp>
13 #include <turtle_brains/graphics/tb_animated_sprite.hpp>
14 #include <turtle_brains/graphics/tb_sprite_sheet.hpp>
15 #include <turtle_brains/core/tb_noncopyable.hpp>
16 #include <turtle_brains/core/tb_string.hpp>
17 
18 #include <map>
19 
20 namespace tbImplementation { struct LoadingSheetInformation; }
21 
22 namespace TurtleBrains
23 {
24  namespace Core { class DynamicStructure; }
25 
26  namespace Graphics
27  {
28 
34  {
35  public:
40  SpriteManager(void);
41 
46  ~SpriteManager(void);
47 
93  bool LoadSpriteSheetFromFile(const tbCore::tbString& spriteSheetName, const tbCore::tbString& spriteSheetFile);
94 
105  bool AddSpriteSheet(const tbCore::tbString& spriteSheetName, const SpriteSheet& spriteSheet);
106 
114  TextureHandle GetSpriteSheetTextureHandle(const tbCore::tbString& spriteSheetName) const;
115 
126  SpriteFrame GetSpriteFrame(const tbCore::tbString& spriteSheetName, const tbCore::tbString& spriteName) const;
127 
145  Sprite GetSpriteFromFile(const tbCore::tbString& textureFile, const PixelSpace& frameX = 0, const PixelSpace& frameY = 0,
146  const PixelSpace& frameWidth = 0, const PixelSpace& frameHeight = 0) const;
147 
158  Sprite GetSprite(const tbCore::tbString& spriteSheetName, const tbCore::tbString& spriteName) const;
159 
171  AnimatedSprite GetAnimatedSprite(const tbCore::tbString& spriteSheetName, const tbCore::tbString& spriteName) const;
172 
182  void AddAnimationSequences(const tbCore::tbString& spriteSheetName, const tbCore::tbString& spriteName, AnimatedSprite& animatedSprite) const;
183 
184  private:
185  void AddAnimationSequences(const SpriteSheet& spriteSheet, const tbCore::tbString& spriteName, AnimatedSprite& animatedSprite) const;
186 
187  bool LoadAllAnimationSequences(SpriteSheet& spriteSheet, const tbCore::tbString& forSprite,
188  const tbCore::DynamicStructure& animationSequences, const tbImplementation::LoadingSheetInformation& loadingInfo);
189  bool LoadAnimationSequence(SpriteSheet& spriteSheet, std::vector<tbCore::tbString>& globalAnimationNames,
190  const tbCore::DynamicStructure& animationData, const tbCore::tbString& forSprite, const tbImplementation::LoadingSheetInformation& loadingInfo);
191  bool LoadAllSpriteMaps(const tbCore::DynamicStructure& spriteSheetData, std::map<tbCore::tbString, SpriteMap>& spriteMaps,
192  const tbImplementation::LoadingSheetInformation& loadingInfo);
193  bool LoadSpriteFrame(SpriteSheet& spriteSheet, const tbCore::DynamicStructure& frameData, const tbImplementation::LoadingSheetInformation& loadingInfo);
194 
195  typedef std::map<tbCore::tbString, SpriteSheet> SpriteSheetContainer;
196  SpriteSheetContainer mSpriteSheets;
197  };
198 
204 
205  }; /* namespace Graphics */
206 }; /* namespace TurtleBrains */
207 
209 
210 #endif /* TurtleBrains_SpriteManager_hpp */
TextureHandle GetSpriteSheetTextureHandle(const tbCore::tbString &spriteSheetName) const
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
Definition: tb_sprite.hpp:29
Definition: tb_sprite_manager.hpp:33
AnimatedSprite GetAnimatedSprite(const tbCore::tbString &spriteSheetName, const tbCore::tbString &spriteName) const
Definition: tb_noncopyable.hpp:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
SpriteFrame GetSpriteFrame(const tbCore::tbString &spriteSheetName, const tbCore::tbString &spriteName) const
bool AddSpriteSheet(const tbCore::tbString &spriteSheetName, const SpriteSheet &spriteSheet)
Sprite GetSprite(const tbCore::tbString &spriteSheetName, const tbCore::tbString &spriteName) const
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.hpp:36
Definition: tb_dynamic_structure.hpp:37
void AddAnimationSequences(const tbCore::tbString &spriteSheetName, const tbCore::tbString &spriteName, AnimatedSprite &animatedSprite) const
Definition: tb_sprite_sheet.hpp:33
bool LoadSpriteSheetFromFile(const tbCore::tbString &spriteSheetName, const tbCore::tbString &spriteSheetFile)
std::string tbString
Definition: tb_string.hpp:335
SpriteManager theSpriteManager
Definition: tb_application_dialog.hpp:19
Definition: tb_animated_sprite.hpp:119
Definition: tb_sprite.hpp:136
Sprite GetSpriteFromFile(const tbCore::tbString &textureFile, const PixelSpace &frameX=0, const PixelSpace &frameY=0, const PixelSpace &frameWidth=0, const PixelSpace &frameHeight=0) const