javascript - jQuery: Pause button to pause all other actions -



javascript - jQuery: Pause button to pause all other actions -

i'm making little game , have button pause game. how can "pause" game doing actions, when clicking "resume" resume actions if nil happened?

let's have complex coding, can't implement little thing in 1 function: needs cover "busy" things.

thank time!

pause button:

function pausegamebtn() { $("#pause").click(function() { if (pausebtnclicked == true) { // ... } else { // ... } }); }

a typical game loop goes through single point of code. timer phone call regularly , single place need check paused state.

this simplified, basic thought is:

var paused = false; // endless game loop setinterval(function(){ if (!paused){ rungameloop(); // process input => calculate => render etc } }, 50); $("#pause").click(function() { paused = true; }); $("#resume").click(function() { paused = false; });

javascript jquery function resume

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -