refactor(levels): use a gamecore timer to handle debris diseappearing
This commit is contained in:
parent
39a998d773
commit
8a9dc05c61
|
@ -4,9 +4,10 @@ local Debris = Entity:extend()
|
|||
|
||||
function Debris:new(world, x, y, speed, dir, timelimit)
|
||||
Debris.super.new(self, world, "debris", x - 4, y - 4, 8, 8)
|
||||
self.life = 0;
|
||||
self.timer = 0
|
||||
self.timelimit = timelimit or 2
|
||||
local timelimit = timelimit or 2
|
||||
|
||||
self:addTimer("timelimit", timelimit)
|
||||
|
||||
self:setMotionDirection(dir, speed)
|
||||
self:setGravityFlag(true)
|
||||
self:setBounceFactor(0.5)
|
||||
|
@ -31,9 +32,10 @@ function Debris:updateEnd(dt)
|
|||
if (isInsideView == false) then
|
||||
self:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
self.timer = self.timer + dt
|
||||
if (self.timer >= self.timelimit) then
|
||||
function Debris:timerResponse(timer)
|
||||
if (timer == "timelimit") then
|
||||
self:destroy()
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue