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

FlxBitmapText, textColor not applied correctly #2916

Closed
13rice opened this issue Sep 21, 2023 · 2 comments · Fixed by #2918
Closed

FlxBitmapText, textColor not applied correctly #2916

13rice opened this issue Sep 21, 2023 · 2 comments · Fixed by #2918
Labels
Bug Easy Change Good for first-time contributors

Comments

@13rice
Copy link
Contributor

13rice commented Sep 21, 2023

  • Haxe version: 4.0.2
  • Flixel version: 5.2.2
  • OpenFL version: 9.1.0
  • Lime version: 7.9.0
  • Affected targets: html5

Code snippet reproducing the issue:

package;

package;

import flixel.FlxState;
import flixel.graphics.frames.FlxBitmapFont;
import flixel.text.FlxBitmapText;
import openfl.Assets;

class PlayState extends FlxState
{
	override public function create()
	{
		super.create();

		// Assets from the FlxBitmapText demo
		var textBytes = Assets.getText("assets/NavTitle.fnt");
		var XMLData = Xml.parse(textBytes);
		var fontAngelCode = FlxBitmapFont.fromAngelCode("assets/NavTitle.png", XMLData);

		var tf = new FlxBitmapText(fontAngelCode);
		tf.useTextColor = true;
		tf.textColor = 0xff223344;
		tf.text = "Hello World!\nand this is\nmultiline!!!";
		add(tf);
	}
}

Observed behavior:
Incorrect text color.
The color of the text is full white, instead of a dark blue green.

Expected behavior:
Apply the text color correctly (see pictures attached).

I dug in the FlxBitmapText class, the alpha isn't applied correctly when we assign a textColor, see around line 348

				tAlpha *= textColor.alpha;

With the following attribute it's working correctly for me (html5 target):

				tAlpha *= textColor.alphaFloat;

Current behavior:
current behavior
Expected behavior:
expected behavior

@Geokureli Geokureli added Bug Easy Change Good for first-time contributors labels Sep 23, 2023
@Geokureli
Copy link
Member

I dug in the FlxBitmapText class, the alpha isn't applied correctly when we assign a textColor, see around line 348

				tAlpha *= textColor.alpha;

With the following attribute it's working correctly for me (html5 target):

				tAlpha *= textColor.alphaFloat;

Good find!

Feel free to make a pull request to fix this, if you're new to open source development this is a great opportunity to learn. Here is a guide for first-time contributors, but, if you have any trouble, reach out

@13rice
Copy link
Contributor Author

13rice commented Sep 23, 2023

Yes ok ! I wanted to submit it first. In the meantime I checked my fix on Windows and Android targets, all fine.
I'll do the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Easy Change Good for first-time contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants