flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Major jittering when scaling and rotating sprites

Open JoeCreates opened this issue 9 years ago • 7 comments

  • 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.

JoeCreates avatar Sep 16 '16 18:09 JoeCreates

Looks like it started after my change in https://github.com/HaxeFlixel/flixel/commit/462d76d7ab0c2de1f355de2231b29f6dcbdba983

JoeCreates avatar Sep 16 '16 18:09 JoeCreates

This should probably be looked into before 4.2.0 is released, since it's sort of a regression.

Gama11 avatar Sep 19 '16 08:09 Gama11

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.

JoeCreates avatar Sep 21 '16 07:09 JoeCreates

Right, that's why I said "sort of a regression" - can't really think of a better label. :)

Gama11 avatar Sep 21 '16 08:09 Gama11

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 avatar May 26 '17 15:05 besserwisser

@besserwisser Its pixelperfectrender you want to set to false, not pixelperfectposition.

JoeCreates avatar May 26 '17 19:05 JoeCreates

@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

besserwisser avatar May 29 '17 07:05 besserwisser