example/plateform: animate the player
This commit is contained in:
parent
53df3c125c
commit
f71c3b3548
1 changed files with 14 additions and 0 deletions
|
@ -27,6 +27,20 @@ function Player:update(dt)
|
|||
self:setDirection(self.xsp)
|
||||
|
||||
Player.super.update(self, dt)
|
||||
self:setAnimation()
|
||||
end
|
||||
|
||||
function Player:setAnimation()
|
||||
self:setCustomSpeed(math.abs(self.xsp) / 12)
|
||||
if (self.onGround) then
|
||||
if math.abs(self.xsp) > 0 then
|
||||
self:changeAnimation("walk", false)
|
||||
else
|
||||
self:changeAnimation("idle", true)
|
||||
end
|
||||
else
|
||||
self:changeAnimation("jump", true)
|
||||
end
|
||||
end
|
||||
|
||||
function Player:setDirection(direction)
|
||||
|
|
Loading…
Reference in a new issue