Platform: Mac
I'm seeing the following error in my console (in yellow text):
error in
__gc metamethod
(
lua_release called on object with retainCount == 0
)
I vaguely understand what that means, but I have no idea why I'm getting it. I am able to track down exactly when/where it's happening in my code, but I guess I don't understand what is causing it.
I have a general "bitmap sprite" class that extends playdate.graphics.sprite:
Bsprite = {}
class('Bsprite').extends(GFX.sprite)
And then I have an "asteroid" class that extends THAT:
Asteroid = {}
class('Asteroid').extends(Bsprite)
And the error occurs every time I spawn a new asteroid from within that asteroid (the asteroid breaks in two - the original updates to the smaller size, and an additional smaller one is also created):
local a2 = getAsteroid()
a2:add()
The "getAsteroid" method just returns either an existing asteroid object from a pool or a new one if the pool is out of asteroids. The error only occurs when the getAsteroid returns a new, fresh instance of an Asteroid object, AND specifically on the "a2:add()" <- if I comment this line out, I no longer get the error. So I can instantiate a new Asteroid, but as soon as I add it to the display list, I see the above error.
Any ideas?