Rewrote text alignment method to work with sprites #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I rewrote the text alignment code to reposition the text in
CanvasText
instead of moving the sprite or mesh object itself. With the current method of text alignment, sprites appear to behave oddly when rotating. This is because sprites always pivot around the origin of the object, so moving the sprite's position itself based on the text size just moves the entire sprite and does not change the pivot point. However, by doing the text alignment in the canvas itself, the sprite's pivot point will remain the same and the text moves around the pivot point appropriately.The only downside to using this method is that the canvas size will be about twice as big as required to render the text, since there needs to be a lot of empty space for left and right alignment.