Good afternoon I would like to adapt the tutorial “Making your first Phaser 3 game” for a second player whose controls are the keys to A W S D.
The problem is that pressing the keys A W S D moves the character but does not perform the animation of the sprites.
function create ()
{
…
this.anims.create({
key: 'left',
frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 3 }),
frameRate: 10,
repeat: -1
});
…
keys = this.input.keyboard.addKeys('A,W,S,D');
cursors = this.input.keyboard.createCursorKeys();
…
}
function update ()
{
if (cursors.left.isDown)
{
player.setVelocityX(-160);
player.anims.play('left', true);
}
// It moves and does the animation.
if (keys.A.isDown){
player.setVelocityX(-160);
player.anims.play('left', true);
}
// It moves but does not do the animation. Why?