Skip to content

Commit

Permalink
Various FlxBar fixes (#2938)
Browse files Browse the repository at this point in the history
- Fixed `frontFrames` graphic not registering as being used
- Render-method-specific variables are now destroyed correctly
- `_frontFrame` is now destroyed when being set to `null`
- Fixed `_frontFrame` documentation
- Removed redundant `positionOffset = null` code

Co-authored-by: Starmapo <[email protected]>
  • Loading branch information
Starmapo and Starmapo authored Oct 31, 2023
1 parent 6a72309 commit 38762cb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions flixel/ui/FlxBar.hx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class FlxBar extends FlxSprite
var _fillHorizontal:Bool;

/**
* FlxSprite which is used for rendering front graphics of bar (showing value) in tile render mode.
* FlxFrame which is used for rendering front graphics of bar (showing value) in tile render mode.
*/
var _frontFrame:FlxFrame;

Expand Down Expand Up @@ -198,9 +198,9 @@ class FlxBar extends FlxSprite
{
positionOffset = FlxDestroyUtil.put(positionOffset);

if (FlxG.renderBlit)
if (FlxG.renderTile)
{
_frontFrame = null;
frontFrames = null;
_filledFlxRect = FlxDestroyUtil.put(_filledFlxRect);
}
else
Expand All @@ -214,7 +214,6 @@ class FlxBar extends FlxSprite
_filledBarPoint = null;

parent = null;
positionOffset = null;
emptyCallback = null;
filledCallback = null;

Expand Down Expand Up @@ -984,8 +983,14 @@ class FlxBar extends FlxSprite
{
if (FlxG.renderTile)
{
if (value != null)
value.parent.incrementUseCount();

if (frontFrames != null)
frontFrames.parent.decrementUseCount();

frontFrames = value;
_frontFrame = (value != null) ? value.frame.copyTo(_frontFrame) : null;
_frontFrame = (value != null) ? value.frame.copyTo(_frontFrame) : FlxDestroyUtil.destroy(_frontFrame);
}
else
{
Expand Down

0 comments on commit 38762cb

Please sign in to comment.