This method is often misunderstood as being a little more magical than it really is; all it does is create and configure a new sprite, and assigns drawCallback
to the new sprite's drawing callback. (it's defined in CoreLibs/sprite.lua
, and actually the entire source is right in the documentation if you would like to see what it does (See: Inside Playdate).
The newly-created sprite is returned from the function, so to remove it you can call :remove()
:
local bgSprite = playdate.graphics.sprite.setBackgroundDrawingCallback(drawCallback)
...
bgSprite:remove()
That said, I think you're right that passing nil
should remove a previously-set background drawing callback. Looking at this also made me realize that if this method is called more than once, you'll end up with multiple background sprites, which feels like a bug to me. I'll file an issue and get a fix ready for this stuff as soon as possible!