Jump to content

Assadhere

Members
  • Posts

    2
  • Joined

  • Last visited

Assadhere's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I'm simply using jquery. I tried this: ////////////////////////////////////////////////////////////// window.addEventListener('keydown', pauseGameKeyHandler, false); function pauseGameKeyHandler(e) { var keyCode = e.keyCode; switch(keyCode){ case 80: //p togglePause(); break; } } function togglePause(e) { if (keyCode == 80) { pause(); } else if (!paused) { pause(); } else if (paused) { resume(); } }; function pause() { paused = true; pauseTime = Date.now(); var pausedElement = document.getElementById( 'paused' ); if( pausedElement ) { pausedElement.style.width = world.width + 'px'; pausedElement.style.height = world.height + 'px'; } document.body.className = 'paused'; } function resume() { var wasPaused = paused; paused = false; time += Date.now() - pauseTime; if( wasPaused ) { timeLastFrame = Date.now(); animate(); } document.body.className = ''; } ///////////////////////////////////////////////////////////////
  2. Hello, I've been searching the internet for a solution to my game. My idea was to pause/resume my game with the 'p' button on my keyboard, which has keycode 80. However, everytime I try to apply a found solution from the internet to my game, it doesn't work or my game doesn't even start. I tried the debugger, I tried using other ways. Is there anyone that can guide me through this or atleast tell me how to do it properly? I've been searching for hours now, and this is an assignment for school. Thanks in advance, Assad
×
×
  • Create New...