![]() |
KTech 1.1.0
C++ 2D terminal game engine library
|
Wrapper for animating an Objects and its Textures.
More...
#include <animation.hpp>
Classes | |
| struct | Instruction |
| A single animation instruction. This class is undocumented because it's planned to change (see GitHub issue #126). | |
Public Member Functions | |
| Animation (Engine &engine, const ID< Object > &object, const std::vector< Instruction > &instructions) | |
Construct an Animation, that will not play just yet. | |
| ~Animation () | |
| Safely cancels invoked animation instructions. | |
| auto | Play () -> bool |
Play the Animation. | |
| void | Stop () |
Stop animation by canceling the invoked instructions, and prepare for a re-Play(). | |
Public Attributes | |
| Engine & | engine |
Parent Engine | |
Wrapper for animating an Objects and its Textures.
Animation contains a vector of Animation::Instructions, which it can play (Animation::Play()), stop (Animation::Stop()), and play again. This wrapper, which behaves like an instruction interpreter, saves you from writing something bonkers like an Object-inherited class that goes through an awkward sequence of Time::Invoke()'d member functions to animate its Textures.
| KTech::Animation::Animation | ( | Engine & | engine, |
| const ID< Object > & | object, | ||
| const std::vector< Instruction > & | instructions ) |
Construct an Animation, that will not play just yet.
To start playing the Animation, call Animation::Play().
| [in] | engine | Reference to parent engine. |
| [in] | object | The object to animate. |
| [in] | instructions | Vector of Animation::Instructions, that Animation::Play() will interpret and "play". |
Animation::Play() | auto KTech::Animation::Play | ( | ) | -> bool |
Play the Animation.
Calling this function again does not replay the Animation; to do so, call Animation::Stop(), and then recall this function.
This function interprets the instructions, acts upon them, Time::Invoke()s itself if there's a delay instruction, and continues interpreting instructions from there.