I’ve got a character that picks up boxes and carries them. I tried using body.facing but if you are moving left and jumping, only UP is set because of the way it’s calculated in body.js.
I’ve calculated both (rough, really needs a flagged enum but just testing) but often y
is -.1.3
when I’m standing still. I’m assuming because of gravity so I’m subtracting 2 as a safety measure but wondered if anyone knows where the difference is coming from rather than guessing at 2?
//get the direction from the velocity
this.direction = {
left: this.body.velocity.x < -2 ? Phaser.Physics.Arcade.FACING_LEFT : 0,
right: this.body.velocity.x > 2 ? Phaser.Physics.Arcade.FACING_RIGHT : 0,
up: this.body.velocity.y < -2 ? Phaser.Physics.Arcade.FACING_UP : 0,
down: this.body.velocity.y > 2 ? Phaser.Physics.Arcade.FACING_DOWN : 0
};