I'm constantly getting this bug, Sprite doesn't have a lua proxy!
. It says it's caused by the moveWithCollisions
method on line 24.
I've run into this bug before, that time I was able to fix it by moving where I handled the garbage collection but that's not the case this time.
This is my bullet class, it says the error pops up on line 24, where the moveWithCollisions
method is. I've already tried adding in some checks to avoid calling after it's been destroyed but it's not helping.
local gfx <const> = playdate.graphics
class("Bullet").extends(Actor)
function Bullet:init(x, y, dx, dy)
Bullet.super.init(self)
self:setGroups({Group.bullet})
self:setCollidesWithGroups({Group.solid})
self:setZIndex(ZIndex.bullet)
self:setImage(_image_bullet)
self:setCollideRect(0,0, self:getSize())
self:moveTo(x, y)
self._to_destroy = false
self.dx = dx * 250 * deltaTime
self.dy = dy * 250 * deltaTime
end
function Bullet:update()
if self._to_destroy then
self:destroy()
else
self:moveWithCollisions(self.x+self.dx, self.y+self.dy)
end
end
function Bullet:collisionResponse(other)
if self._to_destroy then return end
self:setVisible(false)
self:setCollisionsEnabled(false)
self._to_destroy = true
end