From 356054d6dc0fffc280e893ec4385559b4c618de2 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 28 Sep 2017 08:05:15 +0200 Subject: Para-interfacing of walking methods --- not/Player.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index 6996c9d..0b56e6d 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -35,14 +35,14 @@ function Player:update (dt) self:setLinearVelocity(x,-160) self.jumpTimer = self.jumpTimer - dt end +end - -- Walking. - if self:isControlDown("left") then - self:walkLeft() - end - if self:isControlDown("right") then - self:walkRight() - end +function Player:isWalkingLeft () + return self:isControlDown("left") +end + +function Player:isWalkingRight () + return self:isControlDown("right") end -- Controller callbacks. @@ -78,7 +78,6 @@ function Player:controlpressed (set, action, key) -- Walking if (action == "left" or action == "right") then - self.isWalking = true if (self.current ~= self.animations.attack) and (self.current ~= self.animations.attack_up) and (self.current ~= self.animations.attack_down) then @@ -125,7 +124,6 @@ function Player:controlreleased (set, action, key) -- Walking if (action == "left" or action == "right") then if not (self:isControlDown("left") or self:isControlDown("right")) then - self.isWalking = false if self.current == self.animations.walk then self:setAnimation("default") end -- cgit v1.1