Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ class FlxCamera extends FlxBasic
}
}

public function drawPixels(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?blend:BlendMode, ?smoothing:Bool = false,
public function drawPixels(?frame:FlxFrame, ?pixels:BitmapData, matrix:FlxMatrix, ?transform:ColorTransform, ?colored:Bool, ?blend:BlendMode, ?smoothing:Bool = false,
?shader:FlxShader):Void
{
if (FlxG.renderBlit)
Expand All @@ -765,7 +765,11 @@ class FlxCamera extends FlxBasic
}
else
{
var isColored = (transform != null #if !html5 && transform.hasRGBMultipliers() #end);
var isColored:Bool = false;
if(transform != null) {
if(#if !html5 transform.hasRGBMultipliers() #else true #end || colored)
Copy link
Contributor

@Vortex2Oblivion Vortex2Oblivion Sep 28, 2025

Choose a reason for hiding this comment

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

cant you just like

isColored = #if !html5 transform.hasRGBMultipliers()  ||  #end  colored;

Copy link
Author

Choose a reason for hiding this comment

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

Yeah you can! I did it like a separated if for clarity.

isColored = true;
}
var hasColorOffsets:Bool = (transform != null && transform.hasRGBAOffsets());

#if FLX_RENDER_TRIANGLE
Expand Down
31 changes: 23 additions & 8 deletions flixel/FlxSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ class FlxSprite extends FlxObject
/**
* Multiplies this sprite's image by the given red, green and blue components, alpha is ignored.
* To change the opacity use `alpha`. Calling `setColorTransform` will also change this value.
* defaults to flixel.FlxColor.TRANSPARENT for zero tint, to tint a sprite use a non transparent color.
* @see https://snippets.haxeflixel.com/sprites/color/
*/
public var color(default, set):FlxColor = FlxColor.WHITE;
public var color(default, set):FlxColor = FlxColor.TRANSPARENT;

/**
* The color effects of this sprite, changes to `color` or `alpha` will be reflected here
Expand Down Expand Up @@ -367,6 +368,12 @@ class FlxSprite extends FlxObject
@:noCompletion
var _facingFlip:Map<FlxDirectionFlags, {x:Bool, y:Bool}> = new Map<FlxDirectionFlags, {x:Bool, y:Bool}>();

/**
* Tells this `FlxSprite` to batch any color Tint that is not `flixel.FlxColor.TRANSPARENT`
*/
@:noCompletion
var _colored:Bool;

/**
* Creates a `FlxSprite` at a specified position with a specified one-frame graphic.
* If none is provided, a 16x16 image of the HaxeFlixel logo is used.
Expand Down Expand Up @@ -440,6 +447,7 @@ class FlxSprite extends FlxObject
graphic = null;
_frame = FlxDestroyUtil.destroy(_frame);
_frameGraphic = FlxDestroyUtil.destroy(_frameGraphic);
_colored = false;

shader = null;
}
Expand Down Expand Up @@ -898,7 +906,7 @@ class FlxSprite extends FlxObject
matrix.ty = Math.floor(matrix.ty);
}

camera.drawPixels(frame, framePixels, matrix, colorTransform, blend, antialiasing, shader);
camera.drawPixels(frame, framePixels, matrix, colorTransform, _colored, blend, antialiasing, shader);
}

/**
Expand Down Expand Up @@ -1537,12 +1545,19 @@ class FlxSprite extends FlxObject

@:noCompletion
function set_color(value:FlxColor):Int
{
if (color == value)
return value;

color = value;
updateColorTransform();
{
if(value == FlxColor.TRANSPARENT) {
_colored = false;
color = FlxColor.TRANSPARENT;
} else {
if (color == value)
{
return value;
}
color = value;
updateColorTransform();
_colored = true;
}
return color;
}

Expand Down