Hi guys, I have a cannon I want to fire, but with a “held down” mechanic for shot power. What I want to know is whether the “fire cannon” key was pressed and then released (let’s leave the duration part for another post).
This is what I wrote:
fireCannon(){
const keyFireCannon = this.scene.input.keyboard.addKey(FIRE_CANNON);
if (keyFireCannon.isDown){
keyFireCannon.on('keyup', function(){
//const shotAngle = keyFireCannon.duration;
if (this.activeCannon == CANNON_FRONT_ID){
positionMuzzleBlast();
this.muzzleBlast.anims.play('muzzleBlast');
}
});
}
}
But when I press the key, no animation is displayed. All I want to achieve now is for the animation to display.