Class TimerNode

Inheritance Relationships

Base Type

Class Documentation

class TimerNode : public simple2dengine::Node

Timer Node. Used to set timer and execute command on timer finish.

Public Functions

TimerNode(const std::string &nodeName, unsigned int time = 0, bool isOneShot = true)

Construct a new Time Node.

See
Engine.
See
Node.
Parameters
  • nodeName: name of the node.

void setTime(unsigned int time)

Set finish time.

Parameters
  • time: - time until onTimeout will be called.

void start()

Start timer.

void pause()

Pause timer.

void reset()

Reset timer to 0.

bool isPaused() const

Check if timer is paused.

Return
bool pause or not.

void setOneShot(bool oneShot)

Set timer to one shot.

Parameters
  • oneShot: if true - one shot timer.

bool isOneShot() const

Check if timer is one shot.

Return
bool one shot or not.

void onTimeout(std::function<void()> function)

Store a function that will be called when timeout happens. For example you can use it like this:

timer->onTimeout([this] () { sound->stop(); text->setText(“Lose!”); });

Parameters
  • function: lambda function

Protected Functions

virtual void update(int deltaInMs)

Override base update(). We need to calculate.

See
Node.