HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.97k stars 434 forks source link

Jittering caused by sprite offsets #1271

Open JoeCreates opened 10 years ago

JoeCreates commented 10 years ago

One source of jittering not tackled by previous fixes is the fact that sprite offsets can cause graphics to be drawn at floats, even when the sprite itself is supposedly rendering at an integer.

Tiago-Ling commented 9 years ago

Any info on what may be causing this problem? Also, any examples of the effect happening? I have an example showing what i mean by jittering, when the camera is moving you can see the vertical lines of the sprites "trembling" or "shaking": https://github.com/Tiago-Ling/FlixelRenderProblemDemo

Is this the same problem?

JoeCreates commented 9 years ago

@Tiago-Ling There are several causes for jittering. I've managed to get rid of several, but a few still remain, this being one of them.

The other main one is https://github.com/HaxeFlixel/flixel/issues/1022. There is another to do with moving FlxSpriteGroups that contain sprites at floating positions, but I kind of ignore this one because FlxSpriteGroups are so broken anyway.

If you are seeing this issue specifically when you have offsets that are not integers (which can happen if you automatically center the offsets, for example), then it is most likely this (#1271) issue that you are seeing.

There is a different jittering issue that can occur when you are following a sprite with lerp. For some lerp values, a sprite can tremble when it has reached the furthest distance it can from the camera. This particular issue I have no idea how to fix, and it seems to be ubiquitous with low-res games that have lerp on camera follow (e.g. you can see it in many castlevania games).