Clean up dead sprites properly.

This commit is contained in:
Anna Rose Wiggins 2023-09-30 18:23:42 -04:00
parent 9102397c77
commit 5019be454c
4 changed files with 30 additions and 13 deletions

View file

@ -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