|
MochiEngine
|
OneshotAnimation is an AnimatedSprite limited to a single loop of an animation. It features a callback that is called when finishing that animation loop. This makes the class useful for oneshot effects like explosions, and allows to destroy or hide them after finishing. More...
#include <OneshotAnimation.h>
Public Member Functions | |
| OneshotAnimation (IAnimationFactory *, AbstractTextureFactory *, const std::string &animationPath, const std::string &mainAnimation) | |
| 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. | |
| void | SetFinishCallback (std::function< void()> onFinishedCallback) |
| Public Member Functions inherited from 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. | |
| 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) |
Additional Inherited Members | |
| Protected Attributes inherited from Mochi::Graphics::AnimatedSprite | |
| 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 |
OneshotAnimation is an AnimatedSprite limited to a single loop of an animation. It features a callback that is called when finishing that animation loop. This makes the class useful for oneshot effects like explosions, and allows to destroy or hide them after finishing.
Ownership:
Guarantees:
|
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::AnimatedSprite.