From 38762cb196ee0e6e8a05bd925d19306524a925fe Mon Sep 17 00:00:00 2001 From: Starmapo <85134252+Starmapo@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:30:22 -0400 Subject: [PATCH] Various `FlxBar` fixes (#2938) - 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 --- flixel/ui/FlxBar.hx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/flixel/ui/FlxBar.hx b/flixel/ui/FlxBar.hx index a074976722..c32fa6a5de 100644 --- a/flixel/ui/FlxBar.hx +++ b/flixel/ui/FlxBar.hx @@ -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; @@ -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 @@ -214,7 +214,6 @@ class FlxBar extends FlxSprite _filledBarPoint = null; parent = null; - positionOffset = null; emptyCallback = null; filledCallback = null; @@ -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 {