diff options
Diffstat (limited to 'not/Hero.lua')
-rw-r--r-- | not/Hero.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/not/Hero.lua b/not/Hero.lua index 118b9f1..1181080 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -132,7 +132,10 @@ function Hero:update (dt) self:onWalkingStarted() end else - self._already_walking = false + if self._already_walking then + self._already_walking = false + self:onWalkingStopped() + end end if self:isWalkingLeft() then self:walk(-1) @@ -169,7 +172,7 @@ function Hero:update (dt) end --- Called each time Hero starts walking. --- Is not called when only direction of walking is changed. +-- Is not called when direction of walking is changed. function Hero:onWalkingStarted () if (self.current ~= self.animations.attack) and (self.current ~= self.animations.attack_up) and @@ -178,6 +181,16 @@ function Hero:onWalkingStarted () end end +--- Called when Hero stops walking. +-- Is not called when direction of walking is changed. +function Hero:onWalkingStopped () + if not (self:isControlDown("left") or self:isControlDown("right")) then + if self.current == self.animations.walk then + self:setAnimation("default") + end + end +end + function Hero:onJump () -- Start salto if last jump if self.jumpCounter == 1 then |