Fix pause to freeze physics and stop extra runner loops
This commit is contained in:
14
main.js
14
main.js
@@ -24,11 +24,11 @@
|
||||
id: "scene1",
|
||||
name: "Balanced (default)",
|
||||
config: {
|
||||
gravity: 1,
|
||||
spawnIntervalMs: 520,
|
||||
gravity: 0.78,
|
||||
spawnIntervalMs: 720,
|
||||
minChain: 3,
|
||||
palette: ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"],
|
||||
ballRadius: 18,
|
||||
ballRadius: 38,
|
||||
},
|
||||
createBodies: (w, h) => [
|
||||
Bodies.rectangle(w / 2, h + 40, w, 80, {
|
||||
@@ -282,7 +282,7 @@
|
||||
isPaused = false;
|
||||
resetChainVisuals();
|
||||
stopSpawner();
|
||||
Runner.stop(runner);
|
||||
engine.timing.timeScale = 0;
|
||||
pauseOverlay.classList.remove("visible");
|
||||
pauseBtn.textContent = "Pause";
|
||||
finalScoreEl.textContent = score;
|
||||
@@ -302,8 +302,8 @@
|
||||
gameOverEl.classList.remove("visible");
|
||||
pauseOverlay.classList.remove("visible");
|
||||
pauseBtn.textContent = "Pause";
|
||||
engine.timing.timeScale = 1;
|
||||
updateHud();
|
||||
Runner.run(runner, engine);
|
||||
startSpawner();
|
||||
};
|
||||
|
||||
@@ -321,10 +321,10 @@
|
||||
if (isPaused) {
|
||||
resetChainVisuals();
|
||||
stopSpawner();
|
||||
Runner.stop(runner);
|
||||
engine.timing.timeScale = 0;
|
||||
} else {
|
||||
startSpawner();
|
||||
Runner.run(runner, engine);
|
||||
engine.timing.timeScale = 1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user