forked from arne/asdf-games
Added pause function to Game.js
This commit is contained in:
parent
424ce603c1
commit
c52cb48a70
@ -17,6 +17,7 @@ class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.scene = new Container();
|
this.scene = new Container();
|
||||||
|
this.paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
run(gameUpdate = () => { }) {
|
run(gameUpdate = () => { }) {
|
||||||
@ -29,9 +30,11 @@ class Game {
|
|||||||
dt = Math.min(t - last, FRAME_MAX);
|
dt = Math.min(t - last, FRAME_MAX);
|
||||||
last = t;
|
last = t;
|
||||||
|
|
||||||
|
if (!this.paused) {
|
||||||
this.scene.update(dt, t);
|
this.scene.update(dt, t);
|
||||||
gameUpdate(dt, t);
|
gameUpdate(dt, t);
|
||||||
this.renderer.render(this.scene);
|
this.renderer.render(this.scene);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
requestAnimationFrame(loop);
|
requestAnimationFrame(loop);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user