diff --git a/examples/gameplay/moveplayer3D/actors/player.lua b/examples/gameplay/moveplayer3D/actors/player.lua index 0a33ade..85327b8 100644 --- a/examples/gameplay/moveplayer3D/actors/player.lua +++ b/examples/gameplay/moveplayer3D/actors/player.lua @@ -38,6 +38,7 @@ end function Player:setAnimation() local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp) self:setCustomSpeed(math.abs(gsp) / 12) + self:setDirection(self.xsp) if (self.isPunching) then self:changeAnimation("punch", false) else @@ -53,6 +54,14 @@ function Player:setAnimation() end end +function Player:setDirection(direction) + direction = direction or 0 + if direction ~= 0 then + direction = utils.math.sign(direction) + self.direction = direction + self:setSpriteScallingX(direction) + end +end function Player:draw() Player.super.draw(self)