TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Graphics::SpriteSheet Class Reference

#include <tb_sprite_sheet.hpp>

Public Types

typedef std::map< String, AnimationSequenceAnimationSequenceContainer
 

Public Member Functions

 SpriteSheet (const TextureHandle &textureHandle=InvalidTexture())
 
void AddSpriteFrame (const String &spriteName, const SpriteFrame &spriteFrame)
 
const SpriteFrameGetSpriteFrame (const String &spriteName) const
 
void AddAnimationSequence (const String &spriteName, const String &animationName, const AnimationSequence &animationSequence)
 
const AnimationSequenceGetAnimationSequence (const String &animationName) const
 
const AnimationSequenceGetAnimationSequence (const String &spriteName, const String &animationName) const
 
bool AddGlobalAnimationSequencesToSprite (const String &spriteName, const std::vector< String > &animationNames)
 
const AnimationSequenceContainer & GetAnimationSequencesForSprite (const String &spriteName) const
 
void SetTextureHandle (const TextureHandle &textureHandle)
 
const TextureHandleGetTextureHandle (void) const
 

Detailed Description

A sprite sheet is a collection of information regarding the sprites on a particular texture file. Each Sprite has a sprite frame, location and size on the texture and can optionally have animation sequences as well. It would be rare for the SpriteSheet objects to be used directly as the SpriteManager handles the loading of the sprite sheets as well as the creation of the Sprite objects and AnimatedSprite objects.

Note
This shall be considered a TurtleBrains implementation detail. Until further notice do not use the SpriteSheet directly or risk future changes/access loss.

Constructor & Destructor Documentation

◆ SpriteSheet()

TurtleBrains::Graphics::SpriteSheet::SpriteSheet ( const TextureHandle textureHandle = InvalidTexture())
explicit

This is an implementation detail of the SpriteManager and should not be used directly.

Note
The SpriteSheet must have a valid texture before any SpriteFrame objects can be added

Member Function Documentation

◆ AddAnimationSequence()

void TurtleBrains::Graphics::SpriteSheet::AddAnimationSequence ( const String &  spriteName,
const String &  animationName,
const AnimationSequence animationSequence 
)

This is an implementation detail of the SpriteManager and should not be used directly.

Parameters
spriteNameThe name of the sprite to attach the animation to, or if left empty string this will be a global animation sequence for any sprite to use.

◆ AddGlobalAnimationSequencesToSprite()

bool TurtleBrains::Graphics::SpriteSheet::AddGlobalAnimationSequencesToSprite ( const String &  spriteName,
const std::vector< String > &  animationNames 
)

This is an implementation detail of the SpriteManager and should not be used directly.

Returns
True if all animations were added to the sprite, or triggers an error condition.

◆ AddSpriteFrame()

void TurtleBrains::Graphics::SpriteSheet::AddSpriteFrame ( const String &  spriteName,
const SpriteFrame spriteFrame 
)

This is an implementation detail of the SpriteManager and should not be used directly.

Note
The SpriteSheet must have a valid texture before any SpriteFrame objects can be added otherwise an error condition will be triggered. Each SpriteFrame must have the exact TextureHandle or an error condition will be triggered.

◆ GetAnimationSequence() [1/2]

const AnimationSequence& TurtleBrains::Graphics::SpriteSheet::GetAnimationSequence ( const String &  animationName) const

This is an implementation detail of the SpriteManager and should not be used directly.

Note
If no animation sequence exists on the for animationeName an error condition will be triggered.

◆ GetAnimationSequence() [2/2]

const AnimationSequence& TurtleBrains::Graphics::SpriteSheet::GetAnimationSequence ( const String &  spriteName,
const String &  animationName 
) const

This is an implementation detail of the SpriteManager and should not be used directly.

Note
If no animation sequence exists on the for animationeName an error condition will be triggered.

◆ GetAnimationSequencesForSprite()

const AnimationSequenceContainer& TurtleBrains::Graphics::SpriteSheet::GetAnimationSequencesForSprite ( const String &  spriteName) const

This is an implementation detail of the SpriteManager and should not be used directly.

This is an implementation detail of the SpriteManager and should not be used directly.

Note
this will NOT trigger an error condition if sprite doesn't exist it will return empty container.

◆ GetSpriteFrame()

const SpriteFrame& TurtleBrains::Graphics::SpriteSheet::GetSpriteFrame ( const String &  spriteName) const

This is an implementation detail of the SpriteManager and should not be used directly.

Note
If no sprite data exists on the sheet for the spriteName provided an error condition will be triggered.

◆ GetTextureHandle()

const TextureHandle& TurtleBrains::Graphics::SpriteSheet::GetTextureHandle ( void  ) const

This is an implementation detail of the SpriteManager and should not be used directly.

◆ SetTextureHandle()

void TurtleBrains::Graphics::SpriteSheet::SetTextureHandle ( const TextureHandle textureHandle)

This is an implementation detail of the SpriteManager and should not be used directly.

Note
The SpriteSheet must have a valid texture before any SpriteFrame objects can be added.