KTech 1.1.0
C++ 2D terminal game engine library
Loading...
Searching...
No Matches
KTech::Animation Class Reference

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

Engineengine
 Parent Engine
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Animation()

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().

Parameters
[in]engineReference to parent engine.
[in]objectThe object to animate.
[in]instructionsVector of Animation::Instructions, that Animation::Play() will interpret and "play".
See also
Animation::Play()

Member Function Documentation

◆ 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.


The documentation for this class was generated from the following files: