HaxeFlixel / HaxeFlixel/flixel

Error with `FlxBar` rendering if fill direction is changed

Open
#3,256 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Haxe
Stars
2.2k
Forks
522
Avg merge
34m
Merged PRs (30d)
1

Description

  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the flixel.ui.FlxBar entry point and reproduce the issue using the supplied PlayState snippet. Toggle fillDirection with SPACE, then reduce health with RIGHT; done means the bar renders one correct green section rather than two visible sections after the direction changes.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.