代码之家  ›  专栏  ›  技术社区  ›  John

cocos2d:LabelAtlas文本对齐?

  •  1
  • John  · 技术社区  · 17 年前

    cocos2d 0.7.1中是否有方法指定LabelAtlas中的文本对齐方式?

    我使用LabelAtlas作为分数(显示在右上角),但当分数超过10时,第二位数字会被截断。

    谢谢。

    4 回复  |  直到 17 年前
        1
  •  2
  •   James Johnson    16 年前

    虽然这有效,但如果分数超过1000,你也会遇到同样的问题。

    anchorPosition 属性更改位置定义的位置。例如;在我的游戏中,我把 scoreLabel 在屏幕的右下角。为了确保它始终可见,我设置了 锚具位置 位于标签的右下角,然后设置其 position 我希望标签的右下角在哪里。

    [scoreLabel setAnchorPoint:ccp(1, 0)];
    [scoreLabel setPosition:ccp(480, 0)];
    

    [scoreLabel setAnchorPoint:ccp(1, 1)];
    [scoreLabel setPosition:ccp(480, 320)];
    
        2
  •  2
  •   sth    16 年前

    我只是用它来集中我的 LabelAtlas :

    [scoreLabel setAnchorPoint:ccp(.5, .5)];
    

        3
  •  1
  •   John    16 年前

    FWW,我最终确实写了代码来做到这一点。

        if(delegate.score > 99) {
            [scoreLabel setPosition:ccp(374, 265)];
        } else if(delegate.score > 9) {
            [scoreLabel setPosition:ccp(410, 265)];
        }