setBackgroundDrawingCallback : Automatically keep track of the current background drawing sprite

Unless I'm mistaken, and according to the docs, when setting a custom background drawing routine the SDK creates a new background sprite with the s in function and adds it, and returns it from the function.

If you call the function a second time, a new sprite is created and added. Since no record of the original sprite is kept in the sdk, we now have two sprites drawing the background.

The naming of this function suggests that calling it would overwrite the previous drawing callback, so it not doing so is unexpected. If this is the expected behaviour then imo, a) the docs should mention that removing the sprite when calling the function again is the user's responsibility, and b) the function should be renamed to createBackgroundSprite.

Otherwise, the SDK should keep track of the current background drawing sprite and remove it automatically when setBackgroundDrawingCallback is called.

I'm being told this functionality is useful for things like parallax scrolling - fine. That makes sense. I think the docs could be improved by explicitly warning about removing the sprite later, though.

Related

Ahaha, a duplicate on top of everything else. Oh well! Thanks Matt <3

1 Like

Dupes are good—shows the issue not a one off