HaxeFlixel / HaxeFlixel/flixel
Can't stamp() FlxBitmapText to FlxSprite [HTML5, HXCPP]
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 2.2k
- Forks
- 522
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
- Haxe version: 3.4.7
- Flixel version: 4.5.1
- OpenFL version: 8.4.1
- Lime version: 7.0.0
- Affected targets: HTML5, HXCPP
Code snippet reproducing the issue:
package;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxBitmapFont;
import flixel.text.FlxBitmapText;
import openfl.Assets;
/**
* ...
* @author Hunter
*/
class ChatBubbleTest extends FlxSprite
{
private static var chatFont:FlxBitmapFont;
public function new():Void
{
super();
var fontData:String = Assets.getText(AssetPaths.arialBitmap_Size14px__fnt);
chatFont = FlxBitmapFont.fromAngelCode(AssetPaths.arialBitmap_Size14px_0__png, Xml.parse(fontData));
generate();
}
public function generate():Void
{
makeGraphic(100, 100, 0xFFFFFFFF);
var chatText:FlxBitmapText = new FlxBitmapText(chatFont);
chatText.text ="bleh bleh bleh";
chatText.multiLine = true;
chatText.color = 0xFF000000;
chatText.lineSpacing = -1;
stamp(chatText);
}
}
Create a new instance of this class and try adding it in the FlxState.
Observed behavior:
On Flash, the text is properly displayed.
On HTML5 and HXCPP, this error message appears:
HTML5:
js__$Boot_HaxeError:
message:
"Cannot stamp to or from a FlxSprite with no graphics."
Expected behavior:
Text should display on all platforms.
@Geokureli explained this to me:
Flash draws letters to a bitmap on text updates and blits that bitmap every draw call, where HTML/CPP renders each letter each draw call
But I still feel there should be a method to stamp text onto FlxSprite.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with FlxSprite.stamp and the FlxBitmapText construction shown in the reproduction, then compare their rendering behavior on Flash, HTML5, and HXCPP. The work is done when stamping the bitmap text onto the sprite displays the text on all affected targets without the no-graphics error.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100