From ce455b1f9900e05239ebeb4478d03a7947321677 Mon Sep 17 00:00:00 2001 From: Starmapo Date: Fri, 13 Oct 2023 23:48:50 -0400 Subject: [PATCH] Various `FlxBar` fixes - 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 --- 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 {