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
Post a Comment