Clean up dead sprites properly.
This commit is contained in:
parent
9102397c77
commit
5019be454c
4 changed files with 30 additions and 13 deletions
|
@ -17,9 +17,17 @@ function Ebi:init()
|
|||
if math.random(2) == 1 then
|
||||
dir = -1
|
||||
end
|
||||
|
||||
self.vector = {x=0, y=dir}
|
||||
|
||||
self:weaponTimer()
|
||||
self.weaponTimer = playdate.timer.new(2500,
|
||||
function()
|
||||
local b = Bullet(2, 1, {x=-1, y=0}, 0x2)
|
||||
b:moveTo(self.x - (self.width/2) - 1, self.y)
|
||||
b:add()
|
||||
end
|
||||
)
|
||||
self.weaponTimer.repeats = true
|
||||
end
|
||||
|
||||
function Ebi:update()
|
||||
|
@ -31,13 +39,7 @@ function Ebi:update()
|
|||
end
|
||||
end
|
||||
|
||||
function Ebi:weaponTimer()
|
||||
local t = playdate.timer.new(1000,
|
||||
function()
|
||||
local b = Bullet(2, 1, {x=-1, y=0}, 0x2)
|
||||
b:moveTo(self.x - (self.width/2) - 1, self.y)
|
||||
b:add()
|
||||
end
|
||||
)
|
||||
t.repeats = true
|
||||
function Ebi:delete()
|
||||
Ebi.super.delete(self)
|
||||
self.weaponTimer:remove()
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue