Skip to content

Fix incorrect coloring of animated sprites with useFramePixels on renderTile #3416

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

Closed
wants to merge 3 commits into from
Closed
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
27 changes: 10 additions & 17 deletions flixel/FlxSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1201,48 +1201,41 @@ class FlxSprite extends FlxObject

updateFramePixels();
}

/**
* Retrieves the `BitmapData` of the current `FlxFrame`. Updates `framePixels`.
*/
public function updateFramePixels():BitmapData
{
if (_frame == null || !dirty)
return framePixels;

// don't try to regenerate frame pixels if _frame already uses it as source of graphics
// if you'll try then it will clear framePixels and you won't see anything
if (FlxG.renderTile && _frameGraphic != null)
{
dirty = false;
return framePixels;
}

var doFlipX:Bool = checkFlipX();
var doFlipY:Bool = checkFlipY();

final doFlipX = checkFlipX();
final doFlipY = checkFlipY();
if (!doFlipX && !doFlipY && _frame.type == FlxFrameType.REGULAR)
{
framePixels = _frame.paint(framePixels, _flashPointZero, false, true);
}
else
{
framePixels = _frame.paintRotatedAndFlipped(framePixels, _flashPointZero, FlxFrameAngle.ANGLE_0, doFlipX, doFlipY, false, true);
}

if (useColorTransform)
{

if (FlxG.renderBlit && useColorTransform)
framePixels.colorTransform(_flashRect, colorTransform);
}


if (FlxG.renderTile && useFramePixels)
{
// recreate _frame for native target, so it will use modified framePixels
_frameGraphic = FlxDestroyUtil.destroy(_frameGraphic);
_frameGraphic = FlxGraphic.fromBitmapData(framePixels, false, null, false);
_frame = _frameGraphic.imageFrame.frame.copyTo(_frame);
}

dirty = false;
return framePixels;
}
Expand Down