From d900efc15b373d065666f891851085d70ec52667 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 9 Apr 2018 01:42:34 +0200 Subject: Added method call when Hero starts walking --- not/Hero.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'not') diff --git a/not/Hero.lua b/not/Hero.lua index 7ef7b4e..37e61c0 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -122,6 +122,16 @@ function Hero:update (dt) end end + --- Walking + -- TODO: Walking is still not satisfactiory. Think of way to improve it. + if self:isWalking() then + if not self._already_walking then + self._already_walking = true + self:onWalkingStarted() + end + else + self._already_walking = false + end if self:isWalkingLeft() then self:walk(-1) end @@ -156,6 +166,12 @@ function Hero:update (dt) end end +--- Called each time Hero starts walking. +-- Is not called when only direction of walking is changed. +function Hero:onWalkingStarted () + +end + function Hero:onJump () -- Start salto if last jump if self.jumpCounter == 1 then -- cgit v1.1