axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

Text alignment doesn't work #1560

Closed Nordsoft91 closed 10 months ago

Nordsoft91 commented 10 months ago

Expected result: text is aligner to the left, adding more characters doesn't move text

Actual result: when mouse is 100 pix or more outside screen, text is shifting

Note: steps above can be modified, bug appears with any kind of text

https://github.com/axmolengine/axmol/assets/9308612/644c93d0-b7ed-43e1-919b-2712cb01dd89

DelinWorks commented 10 months ago

use setAnchorPoint instead of setting the text alignment, text alignment should really be used with setDimension

rh101 commented 10 months ago

@Nordsoft91 As @DelinWorks pointed out, to correctly align text, the label would need to have fixed dimensions. The reason it's moving in your example is simply because the dimensions of the box change, and given it's set to anchor point of Vec2::ANCHOR_MIDDLE by default, you can see how that would affect the left alignment of text.

If you have no other concerns related to this, then please close this issue.