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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -