#The cooldown pattern

4 messages ยท Page 1 of 1 (latest)

deep sable
#
let canShoot;

function init() {
  canShoot = true;
}

function update() {
  if (canShoot && shootButton.isDown) {
    canShoot = false;
    this.time.delayedCall(DURATION, () => {
      canShoot = true;
    });
  }
}
merry pumice
#

Another elegant snippet - thanks!

hallow grove
#

Nice and simple!

half ruin
#

just take care to anonymous function into an update