So I’m new to phaser and found this free sprite with an attack animation. However, when I try to call it using my custom input key ‘strongAttack’ it gets stuck on the first frame. I’m not sure what I’m doing wrong.
update() {
const speed = 2.5;
let playerVelocity = new Phaser.Math.Vector2();
if(this.inputKeys.left.isDown) {
playerVelocity.x = -1;
if (this.inputKeys.left.isDown) {
this.setFlipX(this.velocity.x < -1);
}
} else if (this.inputKeys.right.isDown) {
playerVelocity.x = 1;
}
if (this.inputKeys.right.isDown) {
this.setFlipX(this.velocity.x < 1);
}
if(this.inputKeys.up.isDown) {
playerVelocity.y = -1;
} else if (this.inputKeys.down.isDown) {
playerVelocity.y = 1;
}
playerVelocity.normalize();
playerVelocity.scale(speed);
this.setVelocity(playerVelocity.x,playerVelocity.y);
if(Math.abs(this.velocity.x) > 0.1 || Math.abs(this.velocity.y) > 0.1) {
this.anims.play('knight_run',true);
} else {
this.anims.play('knight_idle',true);
}
***if(this.inputKeys.strongAttack.isDown) {***
*** this.anims.play(‘strongAttack’,true);}***
}
}