refactor(examples): use updateStart(dt) and updateEnd(dt)
Allow to drop easily some instance of calling the parent's same function
This commit is contained in:
parent
1c879b2090
commit
6f59f1e732
2 changed files with 4 additions and 5 deletions
|
@ -7,7 +7,7 @@ function Player:new(world, x, y, id)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:update(dt)
|
function Player:updateStart(dt)
|
||||||
self.xfrc, self.yfrc = 480*3, 480*3
|
self.xfrc, self.yfrc = 480*3, 480*3
|
||||||
|
|
||||||
if self.keys["up"].isDown then
|
if self.keys["up"].isDown then
|
||||||
|
@ -22,8 +22,6 @@ function Player:update(dt)
|
||||||
if self.keys["right"].isDown then
|
if self.keys["right"].isDown then
|
||||||
self.xsp = 120
|
self.xsp = 120
|
||||||
end
|
end
|
||||||
|
|
||||||
Player.super.update(self, dt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:draw()
|
function Player:draw()
|
||||||
|
|
|
@ -8,7 +8,7 @@ function Player:new(world, x, y, id)
|
||||||
self:setYGravity(480)
|
self:setYGravity(480)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:update(dt)
|
function Player:updateStart(dt)
|
||||||
self.xfrc = 480*3
|
self.xfrc = 480*3
|
||||||
|
|
||||||
if self.keys["up"].isPressed and (self.onGround) then
|
if self.keys["up"].isPressed and (self.onGround) then
|
||||||
|
@ -31,8 +31,9 @@ function Player:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:setDirection(self.xsp)
|
self:setDirection(self.xsp)
|
||||||
|
end
|
||||||
|
|
||||||
Player.super.update(self, dt)
|
function Player:updateEnd(dt)
|
||||||
self:setAnimation()
|
self:setAnimation()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue