Closed lampewebdev closed 2 years ago
@lampewebdev Thanks for the excellent bug report!
Definitely not working as expected.
It appears that there is some internal state being shared across in the ex.SpriteFont
that causes the placement to be buggy when re-used in other ex.Text
objects. As a workaround while we work the bug, cloning the spriteFont
seems to work for now (although not ideal).
var textA = new ex.Text({
font: spriteFont.clone(),
text: "1"
});
var textAA = new ex.Actor({
anchor: ex.Vector.Zero,
x: 100,
y: 10,
z: 1,
});
textAA.graphics.add(textA);
game.add(textAA);
var textB = new ex.Text({
font: spriteFont.clone(),
text: "22"
});
var textBA = new ex.Actor({
anchor: ex.Vector.Zero,
x: 100,
y: 30,
z: 2,
});
textBA.graphics.add(textB);
game.add(textBA);
Steps to Reproduce
It works when both text has the same length but breaks when they do not have the same length
Expected Result
Font should be aligned on the X axis
Actual Result
Fonts are not aligned
Environment
Current Workaround
None