flixel
flixel copied to clipboard
Major jittering when scaling and rotating sprites
- Flixel version: github dev
Code snippet reproducing the issue:
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.tweens.FlxTween;
import flixel.ui.FlxButton;
import flixel.math.FlxMath;
class MenuState extends FlxState
{
override public function create():Void
{
FlxG.camera.pixelPerfectRender = true;
super.create();
var spr:FlxSprite = new FlxSprite();
spr.x += 0.5;
add(spr);
spr.screenCenter();
FlxTween.tween(spr.scale, {x: 3, y: 3}, 2, {type: FlxTween.PINGPONG});
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
}
}
This seems to have been introduced in a very recent commit. I'm looking into it now. Sprites jitter around when scaling on rotating.
Looks like it started after my change in https://github.com/HaxeFlixel/flixel/commit/462d76d7ab0c2de1f355de2231b29f6dcbdba983
This should probably be looked into before 4.2.0 is released, since it's sort of a regression.
Mentioned this in chat, but its not really a bug. More just that fact that for complex rendered sprites pixelperfectposititon never worked. Now that it does, gradually scaling things with pixelperfectrender has unexpected results. The solution is to simply set pixelperfectrender to false on things if you want their top left to not be at an exact pixel when it is scaled or rotated, and this will result in the old behaviour of rendering things at float positions.
Right, that's why I said "sort of a regression" - can't really think of a better label. :)
I do have major jittering as well when rotating or moving sprites. It does not matter if I have pixelperfectposition set to false or true. Also undoing the changes in the FlxSprite Class had no impact on it. Also downgrading flixel to 4.1.0 did not have any effect. Even if i just put this in the update loop:
_player.angle += 0.1;
it jitters a lot.
Have you found another solution that I can try?
@besserwisser Its pixelperfectrender you want to set to false, not pixelperfectposition.
@JoeCreates Thanks for your response. I already tried that. It does not work for HTML5, but for example it works for Flash. It seems like the pixelperfectrender setting has no effect in HTML5. I created a new issue. The problem only occurs on HTML5 target so far. https://github.com/HaxeFlixel/flixel/issues/2075