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
BitmapText .textWidth only correct after render? #3461
Comments
Err, it's expected behaviour right now because that's what the code does, but we can make it better ;) You see, text isn't updated until it's renderered for performance reasons. Imagine you had a counter, counting up super fast. You wouldn't want to re-create each number in the text class because it's only when it's rendered that you need it to show the right thing. The normal Text class, for example, makes sure that when you try to get the width of it, it updates the text outside of the rendering loop, to make sure that the value returned is accurate and up to date. BitmapText is not doing this (but it should). Whilst a fix is created, you can call .updateText() on the object before querying .textWidth. This should give you the accurate measurement without having to wait for a rAF |
the fix would be to make the current .textWidth a private ._textWidth, create a read only getter called .textWidth, which calls .validate() before returning ._textWidth; for the getter of .width (and height),, I believe it should call .updateTransform() before returning the width |
.validate is what I was looking for. Thanks :). I'll implement + pr later this evening if I get a chance. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
After setting the .text property of a BitmapText, the .textWidth is incorrect until after a render. Had to use requestAnimationFrame() to wait when doing re positioning calculations. Is this expected behavior?
The text was updated successfully, but these errors were encountered: