From 6f59f1e732a24614ea397bf6a2356b62b505cc85 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 13 Jun 2019 18:44:13 +0200 Subject: [PATCH] refactor(examples): use updateStart(dt) and updateEnd(dt) Allow to drop easily some instance of calling the parent's same function --- examples/gameplay/moveplayer/actors/player.lua | 4 +--- examples/gameplay/plateform/actors/player.lua | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/gameplay/moveplayer/actors/player.lua b/examples/gameplay/moveplayer/actors/player.lua index 9877bff..a752c38 100644 --- a/examples/gameplay/moveplayer/actors/player.lua +++ b/examples/gameplay/moveplayer/actors/player.lua @@ -7,7 +7,7 @@ function Player:new(world, x, y, id) end -function Player:update(dt) +function Player:updateStart(dt) self.xfrc, self.yfrc = 480*3, 480*3 if self.keys["up"].isDown then @@ -22,8 +22,6 @@ function Player:update(dt) if self.keys["right"].isDown then self.xsp = 120 end - - Player.super.update(self, dt) end function Player:draw() diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index 86f7a30..2f18947 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -8,7 +8,7 @@ function Player:new(world, x, y, id) self:setYGravity(480) end -function Player:update(dt) +function Player:updateStart(dt) self.xfrc = 480*3 if self.keys["up"].isPressed and (self.onGround) then @@ -31,8 +31,9 @@ function Player:update(dt) end self:setDirection(self.xsp) +end - Player.super.update(self, dt) +function Player:updateEnd(dt) self:setAnimation() end