Ogre::Timer _timer;
_timer.reset();
if(_key->isKeyDown(OIS::KC_R) && _timer.getMilliseconds() > 250) {
_timer.reset();
We used another new class from Ogre 3D, namely, Ogre::Timer
. This class offers, as the name suggests, timer functionality. We reset the timer in the constructor of our listener and every time the user presses the R key, we check if 0.25 seconds have passed since the last time we called reset()
. If this is the case, we enter the if
block and the first thing we do is reset the timer and then change the render mode like before. This makes sure that the render mode is only changed after 0.25 seconds. When we keep pressing the R key, we see that our application changes through all render modes with a wait of 0.25 seconds after each change.
18.119.126.165