From c52cb48a70b2562d8ddf24331b9a1d1633c799fd Mon Sep 17 00:00:00 2001 From: Arne van Iterson Date: Fri, 17 Apr 2020 00:15:42 +0200 Subject: [PATCH] Added pause function to Game.js --- lib/Game.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Game.js b/lib/Game.js index dba0729..b56cbfc 100644 --- a/lib/Game.js +++ b/lib/Game.js @@ -17,6 +17,7 @@ class Game { } this.scene = new Container(); + this.paused = false; } run(gameUpdate = () => { }) { @@ -29,9 +30,11 @@ class Game { dt = Math.min(t - last, FRAME_MAX); last = t; - this.scene.update(dt, t); - gameUpdate(dt, t); - this.renderer.render(this.scene); + if (!this.paused) { + this.scene.update(dt, t); + gameUpdate(dt, t); + this.renderer.render(this.scene); + } }; requestAnimationFrame(loop); }