navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 3 (modified by landauf, 3 years ago) (diff)

fixed links

HowTo: Tickable

A tick is one frame or one iteration of the main-loop. Classes can be called every tick. This is achieved by inheriting from doc/Tickable and implementing the virtual void tick(float dt) function. dt is the time in seconds passed since the last tick.

*.h file:

#include "objects/Tickable.h"

class MyClass : public Tickable
        virtual void tick(float dt);

        Vector3 position_;

*.cc file:

void MyClass::tick(float dt)
    // let the object move with 100 units per second in positive x direction:
    Vector3 velocity(100, 0, 0);
    this->position_ += velocity * dt;

    // call tick(dt) of the parent class:
    SUPER(MyClass, tick, dt);

(See this for more information about the SUPER macro.)