Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
Public Member Functions | Public Attributes | List of all members
Animation Class Reference

Public Member Functions

 Animation (int startTime, int duration, std::function< void(float)> onStep, std::function< void()> onFinish)
 
bool isFinished ()
 
bool step ()
 

Public Attributes

int startTime = 0
 
int duration = 0
 
std::function< void(float)> onStep = NULL
 
std::function< void()> onFinish = NULL
 

Detailed Description

Definition at line 4 of file Animation.hpp.

Constructor & Destructor Documentation

◆ Animation()

Animation::Animation ( int  startTime,
int  duration,
std::function< void(float)>  onStep,
std::function< void()>  onFinish 
)

Definition at line 4 of file Animation.cpp.

4 {
5 this->startTime = startTime;
6 this->duration = duration;
7 this->onStep = onStep;
8 this->onFinish = onFinish;
9}

Member Function Documentation

◆ isFinished()

bool Animation::isFinished ( )

Definition at line 11 of file Animation.cpp.

11 {
12 return CST_GetTicks() > startTime + duration;
13}

◆ step()

bool Animation::step ( )

Definition at line 15 of file Animation.cpp.

15 {
16 if (isFinished()) {
17 onFinish();
18 return true;
19 }
20
21 if (onStep != NULL) {
22 float progress = (float)(CST_GetTicks() - startTime) / (float)duration;
23 onStep(progress);
24 }
25 return false;
26}

Member Data Documentation

◆ duration

int Animation::duration = 0

Definition at line 12 of file Animation.hpp.

◆ onFinish

std::function<void()> Animation::onFinish = NULL

Definition at line 14 of file Animation.hpp.

◆ onStep

std::function<void(float)> Animation::onStep = NULL

Definition at line 13 of file Animation.hpp.

◆ startTime

int Animation::startTime = 0

Definition at line 11 of file Animation.hpp.


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