Use the color
property of a FlxSprite
to tint a sprite’s graphic to a specific color. This applies the color to the whole graphic uniformly.
// sprite will be tinted red sprite.color = 0xff0000;
Use the color
property of a FlxSprite
to tint a sprite’s graphic to a specific color. This applies the color to the whole graphic uniformly.
// sprite will be tinted red sprite.color = 0xff0000;
package; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; import flixel.util.FlxColor; class PlayState extends FlxState { var hue:Float = 0; var sprite:FlxSprite; override public function create() { super.create(); sprite = new FlxSprite("assets/bigbox.png"); sprite.screenCenter(); add(sprite); } override public function update(elapsed:Float) { hue += elapsed * 50; if (hue > 360) hue -= 360; var color = FlxColor.fromHSB(Std.int(hue), 1, 1); sprite.color = color; super.update(elapsed); } }