Should you call playdate.graphics.sprite.update in a class that inherits from sprite?

,

I've been following this tutorial, and was wondering whether it is recomended to call playdate.graphics.sprite.update in a classes update loop if they inherit from a sprite? I'm not sure if gfx.sprite.update will run before or after the update function in the new class, meaning the sprite might end up behind where it should be.

You can update sprites at any time, from anywhere, but what you'll see on screen is the state of the sprites as they are at the end of playdate.update()

You can prove this quite easily with some simple experimentation.

So just to keep things understandable you should probably minimise the amount of sprite updates.

so, in other words, it shouldn't matter whether I call it or not, because all the variables in the sprite work out the same, even if they get displayed slightly later? does this also apply to collisions?

No, it matters if you call it as the changes will happen, but you'll only see the state of the sprite as it as at the end of the main update.

Yes it also applies to collisions.

Just try it :slight_smile: