I have a character that has a click to point movement. I'm using MoveToObject I want to implement an animation to the sprite based on the direction it's moving similar to this code snippet below
if (this.cursors.left.isDown)
{
this.player.setVelocity(-speed, 0)
this.player.play('left-walk', true)
}
else if (this.cursors.right.isDown)
{
this.player.setVelocity(speed, 0)
this.player.play('right-walk', true)
}
else if (this.cursors.up.isDown)
{
this.player.setVelocity(0, -speed)
this.player.play('up-walk', true)
}
else if (this.cursors.down.isDown)
{
this.player.setVelocity(0, speed)
this.player.play('down-walk', true)
}
I'm guessing getting the current angle of the sprite but I can't seem to make it work. Thank you