|
MochiEngine
|
Spritesheet takes all the functionality of SpriteBase, generates animation data for the texture, and expects it to be used manually. More...
#include <Spritesheet.h>
Public Member Functions | |
| Spritesheet (IAnimationFactory *animationFactory, AbstractTextureFactory *textureFactory, const std::string &animationPath, const int &startingFrame) | |
| Constructs the spritesheet with the default SpriteBase constructor, internally calling LoadTexture. | |
| void | SetFrame (const int &frameIndex) |
| Sets the current frame for the animation. | |
| int | GetFrame () const |
| Gets the current frame index. | |
| Public Member Functions inherited from Mochi::Graphics::SpriteBase | |
| SpriteBase (AbstractTextureFactory *factory, const std::string &path) | |
| Constructor that internally calls LoadTexture(AbstractTextureFactory *textureFactory, const std::string &filename). | |
| SpriteBase () | |
| This constructor only initializes a minimal part of the sprite. LoadTexture(AbstractTextureFactory *textureFactory, const std::string &filename) needs to be called for the sprite to be valid. | |
| void | LoadTexture (AbstractTextureFactory *textureFactory, const std::string &path) |
| Loads the texture and caches its size for future rendering. | |
| virtual std::vector< RenderCommand > | GetRenderData () const |
| Gets the list of render commands that represent this sprite in a format compatible with the renderer. | |
| virtual void | Update (const float &dt) |
| Overridable api to work with animated sprites. | |
| void | SetZIndex (const uint16_t &zIndex) |
| uint16_t | GetZIndex () const |
| bool | IsVisible () const |
| void | SetVisible (const bool &visible) |
| uint8_t | GetAlpha () const |
| void | SetAlpha (const uint8_t &alpha) |
| std::shared_ptr< Transform > | GetTransform () const |
| void | SetTransform (std::shared_ptr< Transform > tr) |
| void | SetSrcRect (const Rectf &src) |
Protected Attributes | |
| std::shared_ptr< AnimationsData > | mAnimationsData |
| Protected Attributes inherited from Mochi::Graphics::SpriteBase | |
| std::shared_ptr< ITexture > | mTexture |
| Rectf | mSrcRect |
| uint16_t | mZindex |
| bool | mVisible |
| uint8_t | mAlpha |
| Vector2f | mSize |
| std::shared_ptr< Transform > | mTransform |
Spritesheet takes all the functionality of SpriteBase, generates animation data for the texture, and expects it to be used manually.
This means that the Spritesheet generates a texture containing several sprites, and the user is responsible to change frames.
This has several uses. If a sprite has animations that are not represented with traditional flows (forward, backward, pingpong) this allows to change the frames manually. It also works to create sprite atlases and improve performance, using the same texture for a lot of different sprites.
Ownership:
Guarantees:
Not responsible:
| Mochi::Graphics::Spritesheet::Spritesheet | ( | IAnimationFactory * | animationFactory, |
| AbstractTextureFactory * | textureFactory, | ||
| const std::string & | animationPath, | ||
| const int & | startingFrame ) |
Constructs the spritesheet with the default SpriteBase constructor, internally calling LoadTexture.
| animationFactory | The animation factory. |
| textureFactory | The texture factory. |
| animationPath | The path or unique identifier to the animation file in the file system. |
| startingFrame | The first frame the sprite will show. |
| int Mochi::Graphics::Spritesheet::GetFrame | ( | ) | const |
Gets the current frame index.
| void Mochi::Graphics::Spritesheet::SetFrame | ( | const int & | frameIndex | ) |
Sets the current frame for the animation.
| frameIndex | A 0 based index of which texture is going to be shown. |