#The cooldown pattern
4 messages ยท Page 1 of 1 (latest)
4 messages ยท Page 1 of 1 (latest)
let canShoot;
function init() {
canShoot = true;
}
function update() {
if (canShoot && shootButton.isDown) {
canShoot = false;
this.time.delayedCall(DURATION, () => {
canShoot = true;
});
}
}
Another elegant snippet - thanks!
Nice and simple!
just take care to anonymous function into an update