【问题标题】:cocos2d coordinates systemcocos2d 坐标系
【发布时间】:2011-06-01 21:18:46
【问题描述】:
        CCLabelTTF *label = [CCLabelTTF labelWithString:@"Score : #" fontName:@"Arial" fontSize:14];

        // ask director the the window size
        CGSize size = [[CCDirector sharedDirector] winSize];

        // position the label on the center of the screen
        label.position =  ccp( size.width + 0, size.height + 0 );

        // add the label as a child to this Layer
        [self addChild: label];

        label.position =  ccp( size.width + 0, size.height + 0 );

我如何在左下角获得该标签。我不太了解坐标系。据我了解,Y 是底部。 X在最左边。那么当我使用该代码时,标签的位置是右上角的。我的应用是纵向的。

最好将标签作为一个精灵,或者就这样保持它。 (它持有分数)

【问题讨论】:

    标签: iphone ios4 cocos2d-iphone


    【解决方案1】:

    在 codos2d 中,点 (0,0) 是屏幕的左下角。将其想象为 x,y 平面上的象限 1,其中 x 向右增加,y 向上增加。

    所以要获取左下角的标签,只需执行label.position = ccp(0, 0); 但这可能是默认设置,因此您可能无需执行任何操作。

    【讨论】:

      【解决方案2】:

      考虑第一个问题的第一个答案,第二个问题的答案是,如果标签用于得分,那么最好使用标签,而不是精灵(因为你需要 1000 个它们,而且它会很重也很复杂)

      【讨论】:

        【解决方案3】:

        如果快速更新(每秒多次)CCLabelTTF 会很昂贵,但如果您不更新它就可以了。一种首选方法是使用 CCLabelBMFont (我认为这是类......)。您需要 .fnt 文件和 .png 来配合它,但您可以使用 71squared 的 Glyph Designer 等工具制作它们。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多