feat(moveplayer3D): add sprite direction
This commit is contained in:
parent
940cb1b41f
commit
cdddc79973
1 changed files with 9 additions and 0 deletions
|
@ -38,6 +38,7 @@ end
|
||||||
function Player:setAnimation()
|
function Player:setAnimation()
|
||||||
local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp)
|
local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp)
|
||||||
self:setCustomSpeed(math.abs(gsp) / 12)
|
self:setCustomSpeed(math.abs(gsp) / 12)
|
||||||
|
self:setDirection(self.xsp)
|
||||||
if (self.isPunching) then
|
if (self.isPunching) then
|
||||||
self:changeAnimation("punch", false)
|
self:changeAnimation("punch", false)
|
||||||
else
|
else
|
||||||
|
@ -53,6 +54,14 @@ function Player:setAnimation()
|
||||||
end
|
end
|
||||||
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()
|
function Player:draw()
|
||||||
Player.super.draw(self)
|
Player.super.draw(self)
|
||||||
|
|
Loading…
Reference in a new issue