flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Error with `FlxBar` rendering if fill direction is changed

Open DetectiveBaldi opened this issue 1 year ago • 0 comments

  • Haxe version: 4.3.6
  • Flixel version: git
  • OpenFL version: git
  • Lime version: git
  • Affected targets: all

https://github.com/user-attachments/assets/66ed2309-fa28-4e5a-97e1-be4da9293971

the issue can be reproduced with this snippet:

package;

import flixel.FlxG;
import flixel.FlxState;
import flixel.ui.FlxBar;
import flixel.util.FlxColor;

class PlayState extends FlxState
{
	var health:Float = 50.0;

	var flx:FlxBar;

	override public function create()
	{
		super.create();

		flx = new FlxBar(0.0, 0.0, RIGHT_TO_LEFT, 640, 25, this, "health", 0.0, 100.0, true);

		flx.createFilledBar(0xFF66FF33, FlxColor.RED, true, FlxColor.BLACK, 5);

		add(flx);
	}

	override public function update(elapsed:Float)
	{
		super.update(elapsed);

		if (FlxG.keys.pressed.RIGHT)
			health--;

		if (FlxG.keys.pressed.LEFT)
			health++;

		if (FlxG.keys.justPressed.SPACE)
		{
			flx.fillDirection = flx.fillDirection == LEFT_TO_RIGHT ? RIGHT_TO_LEFT : LEFT_TO_RIGHT;

			trace("updated fill dir");
		}
	}
}

by pressing space, and then pressing right to reduce the health, which results in 2 visible green sects

DetectiveBaldi avatar Sep 25 '24 22:09 DetectiveBaldi