summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--not/Hero.lua17
-rw-r--r--not/Player.lua8
2 files changed, 15 insertions, 10 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
diff --git a/not/Player.lua b/not/Player.lua
index 5e73e25..b33e229 100644
--- a/not/Player.lua
+++ b/not/Player.lua
@@ -65,14 +65,6 @@ function Player:controlreleased (set, action, key)
if action == "jump" then
self.jumpTimer = Hero.JUMP_TIMER
end
- -- Walking
- if (action == "left" or action == "right") then
- if not (self:isControlDown("left") or self:isControlDown("right")) then
- if self.current == self.animations.walk then
- self:setAnimation("default")
- end
- end
- end
end
return Player