I noticed that when placing 2 sprites next to each other, and move them across the screen at the same speed, they occasionally run "of of sync": One of them will seemingly skip an update and get a pixel behind the other one.
The issue is reproducible and easily visible when looking at the included 2020 example, and changing the vertical speeds of all sprites to 1:
Source.zip (38.6 KB)
2020.pdx.zip (36.7 KB)
In the example above, the jittering of airplanes is very noticeable against the background, both on simulator and actual device.
I tried to simplify the update routines, play around with ZIndexes and update the sprites manually, but the problem persists. Any suggestions as to what could cause this?
Hm. Looks like they shift right when the top of the sprite hits the top of the screen. Seems like a rounding issue? Ohhhh I bet it's on a half pixel and it's rounding toward zero--when the top's at -0.5 it's displayed at y=0, and one step later when it's at 0.5 you get exactly the same thing. Adding 0.5 to the initial y value is one way to fix the problem. We should be rounding towards negative instead. I'll file it!
Yes, it’s indeed rounding the sprite position. As pointed out by debugChicken on Discord, this specifically happens here because the anchor point of a sprite is set to the center, and its image is not an even-size. Cropping the image so its dimensions are even (eg adding a row of transparent pixels) or using
Sprite:setCenter(0,0) resolves the issue.
I could imagine having a different method of rounding could give more predictable results (I’m not sure how it’s implemented currently), or alternatively have a way to set the sprite center with specific coordinates rather than a fraction (so you could round it down manually).
Anyway, ensuring that all sprites are of even size is a good enough solution for me. I’ll leave it up to you whether/how to make changes to the SDK
The fix for this is in today's 2.3 update. Please let us know if you're still seeing this after updating!