|
MochiEngine
|
AnimatedSprite does all the Spritesheet does and also provides an easy interface to animate and select animations for the sprite. More...
#include <AnimatedSprite.h>
Public Member Functions | |
| AnimatedSprite (IAnimationFactory *animationFactory, AbstractTextureFactory *textureFactory, const std::string &animationPath, const std::string &mainAnimation) | |
| Constructs the spritesheet with the default SpriteBase constructor, internally calling LoadTexture. | |
| virtual void | Update (const float &dt) override |
| This method updates an internal timer and changes frames when needed, according to the rules defined in the AnimationsData metadata. This needs to be called manually to work. | |
| virtual void | PlayAnimation (const std::string &animationName) |
| Given an existing animation name, it starts that animation. This means immediately changing the frame, resetting the timer and setting the current animation. | |
| void | StopAnimation () |
| Stops the current animation and the timer, freezing the sprite in the current frame. | |
| std::string | GetCurrentAnimation () const |
| Public Member Functions inherited from 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. | |
| 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. | |
| 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 | |
| bool | mPlaying |
| float | mTimer |
| int | mLoops |
| bool | mForward |
| std::string | mCurrentAnimation |
| Protected Attributes inherited from Mochi::Graphics::Spritesheet | |
| 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 |
AnimatedSprite does all the Spritesheet does and also provides an easy interface to animate and select animations for the sprite.
AnimatedSprite has the same data as Spritesheet, but also uses the AnimationsData to internally change the frame shown in the spritesheet.
Ownership:
Guarantees:
Limitations:
| Mochi::Graphics::AnimatedSprite::AnimatedSprite | ( | IAnimationFactory * | animationFactory, |
| AbstractTextureFactory * | textureFactory, | ||
| const std::string & | animationPath, | ||
| const std::string & | mainAnimation ) |
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. |
| mainAnimation | The first animation the sprite will show. |
|
virtual |
Given an existing animation name, it starts that animation. This means immediately changing the frame, resetting the timer and setting the current animation.
| animationName | The unique name of the desired animation to play. |
|
overridevirtual |
This method updates an internal timer and changes frames when needed, according to the rules defined in the AnimationsData metadata. This needs to be called manually to work.
| dt | The delta time. |
Reimplemented from Mochi::Graphics::SpriteBase.
Reimplemented in Mochi::Graphics::OneshotAnimation.