Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various FlxBar fixes #2938

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines +201 to +203
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you shed some light on this change? was renderBlit a mistake, or was the comment above wrong? why frontFrames instead of _frontFrames?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_frontFrame and _filledFlxRect are only used in tile render mode, but the current code mistakenly tries to destroy these when the game is using blit render mode, and vice versa for the variables only used in blit mode. Simply changing line 201 to renderTile fixes it.

I changed line 203 to frontFrames as that value is left without being set to null in the current code, and set_frontFrames will also null out _frontFrame.

_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
Loading