Answer the question
In order to leave comments, you need to log in
How to pause a game in javascript?
How to develop a pause in the game? It is necessary that the pause is pressed on the spacebar and after it the entire gameplay stops
Answer the question
In order to leave comments, you need to log in
Purely theoretically, if you assume a lot of things, then maybe so?
$(document).on("keydown", function(e){
if(e.keyCode == 27) {
var gPause = myGame.currentStatus("isPaused");
var frozenData = {};
if(!gPause){
myGame.gameCurrentProcessing.all("stop").currentStatus("paused", true);
frozenData = myGame.detach();
} else {
frozenData.appendTo(document.body);
myGame.gameCurrentProcessing.all("start").currentStatus("paused", false);
}
}
});
Elementrano. To begin with, it is necessary that there is no shitty code and there are clear demarcations in the game where the logic calculation, rendering, etc. takes place. For a pause, you simply stop calculating the logic, leaving everything else, i.e. the world will freeze but will render correctly, in the same way the freeze time is done like everything is frozen and you can fly the camera and evaluate everything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question