I am making a game. I Pause the game by this code in THREE.js
if (keyboard.pressed("E")) {
animate = false;
}
if(animate){
requestAnimationFrame(animate);
}
I want to restart the game after pausing, by pressing any other key but don't know how? Kindly help me in this regard. Thanks.
You could implement some simple jQuery at the document level to simply do this,
$("body").on("keypress", function (e) {
if(!animate) animate = true;
});
...thus even if E
is pressed again, it will unpause. This is assuming you are constantly checking animate on an interval. Otherwise, you could explicitly make a call to your animate procedure inside of the if qualifier
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.