NxOgre.org

Betajaen’s shortguide to NxOgre

Father Time — Controlling time with your time machine

TimeController is the second one in charge, he makes things happen, he makes the whole cause and event thing go, he’s the man.

TimeController* mTimeController = mWorld->getTimeController();

Because Time is a strange thing (and personally I think we would do better without it), anything that needs to be in the time dimension must be a TimeListener. We can do that by inheriting from the TimeListener class;

class myClock : public TimeListener {
 bool advance(const TimeStep& step, const Enums::Priority&) {
  std::cout << "My word! " << step.mActual << " seconds have passed.\n";
 }
};

Lot’s of things in Bloody Mess are TimeListeners; Scenes, some Singletons, Renderables, even the World – although you ask him about it, he’ll deny everything.

With our now time controlling superpowers we can exercise our will to advance time forward as much as we want, as many times as we like!

TimeController* mr_timey_wimey = TimeController::getSingleton();
mr_timey_wimey->advance(100.0f);

With the universe advanced 100 seconds into the future and we did not age a day, our quest for being an evil mastermind is coming to an end.

Previous | TOC | Next

IndexWhat is NxOgre?Guides and TutorialsDownloadForums