timer won't start

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
bobyBola
Posts: 28
Joined: Wed Jan 07, 2009 5:02 am
Location: Indonesia

timer won't start

Post 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??
hai adik2 semua mari kita belajar sambil bermain bersama saya si BOBBY BOLA di edugames bermacam pelajaran bisa didapat ad berhitung menggambar mewarnai tidak ketinggalan dapat belajar nyanyi juga belajar huruf angka & logika bersama BOBBY BOLA semua bisa
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post 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();
      }
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
bobyBola
Posts: 28
Joined: Wed Jan 07, 2009 5:02 am
Location: Indonesia

Post by bobyBola »

i see... and it is working now... thanks for your help Acki... :wink: :wink:
hai adik2 semua mari kita belajar sambil bermain bersama saya si BOBBY BOLA di edugames bermacam pelajaran bisa didapat ad berhitung menggambar mewarnai tidak ketinggalan dapat belajar nyanyi juga belajar huruf angka & logika bersama BOBBY BOLA semua bisa
Post Reply