Page 1 of 1

timer won't start

Posted: Fri Oct 30, 2009 10:19 am
by bobyBola
hi, i tried to pause the game using timer like the code below

Code: Select all

driver->beginScene(true, true, video::SColor(255,0,0,0));
		smgr->drawAll();
		if ( receiver.IsKeyDown(irr::KEY_KEY_U))
		{
			device->getTimer()->stop();
		}
		if ( receiver.IsKeyDown(irr::KEY_KEY_B))
		{
			device->getTimer()->start();
		}
		driver->endScene();
the game will stop but when i press key to start (key B).. it won't start again. :shock: :shock: :shock:

can anybody tell me how to start the timer or i shoud use another way to pause the game??

Posted: Fri Oct 30, 2009 4:03 pm
by Acki
this is because you only check for the key is down, this will do the action(s) multiple times (undefined count) !!! ;)
you need to check if the timer is already stopped...
do it this way:

Code: Select all

      if ( receiver.IsKeyDown(irr::KEY_KEY_U) && !device->getTimer()->isStopped())
      {
         device->getTimer()->stop();
      }else
      if ( receiver.IsKeyDown(irr::KEY_KEY_B) && device->getTimer()->isStopped())
      {
         device->getTimer()->start();
      }

Posted: Sat Oct 31, 2009 1:57 am
by bobyBola
i see... and it is working now... thanks for your help Acki... :wink: :wink: