【问题标题】:CCLabelBMFont for a menu item?菜单项的 CCLabelBMFont?
【发布时间】:2015-06-28 00:10:00
【问题描述】:

嘿,我疯了。我想使用我很酷的 heiro 字体表,我将 CCLabelBMFont 用作标签和分数变量,但不能将它们作为可点击项目放入菜单!但 CCLabelMBFont 明确表示您可以将它们用作菜单项——请参见此处:

详细说明

CCLabelBMFont 是 CCSpriteBatchNode 的子类

特点:

* Treats each character like a CCSprite. This means that each individual character can be:
      o rotated
      o scaled
      o translated
      o tinted
      o chage the opacity
* It can be used as part of a menu item.
* anchorPoint can be used to align the "label"
* Supports AngelCode text format

然而,我浏览了整个网络,找不到任何人将 CCLabelBMFont 作为菜单项的示例。这是我到目前为止的代码:

-(id) 初始化 { if( (self=[super init] )) {

    CCLabelBMFont *homeTest = [CCLabelBMFont labelWithString:@"HomeTEST" fntFile:@"hieroTitle2.fnt"];
    homeTest.position = ccp(0, 0);
    //finalScoreFont.position = ccp(wrapper.position.x, wrapper.position.y-40);
    [self addChild:homeTest z:2 tag:kTagHomeTest];

    /* here's where I am lost and want to put the CCLabelBMFont
    CCMenuItem *homeButton = 
    home.position = ccp(0, 0);

    CCMenu *menu = [CCMenu menuWithItems:homeButton, nil];
    menu.position = ccp(60, 50);
    */

    [self addChild:menu z:3];

}
return self;

}

【问题讨论】:

    标签: cocos2d-iphone


    【解决方案1】:

    我找到了线索和可能的解决方案!看看这个家伙的代码:

    CCLabelBMFont *tlabel = [CCLabelBMFont labelWithString:@"Page 2" fntFile:@"customfont.fnt"];
    CCMenuItemLabel *titem = [CCMenuItemLabel itemWithLabel:tlabel target:self selector:@selector(testCallback:)];
    CCMenu *menu = [CCMenu menuWithItems: titem, nil];
    menu.position = ccp(screenSize.width/2, screenSize.height/2);
    

    不错!他首先制作了标签,然后将CCLabelBMFont 用作CCMenuItemLabel Weeee!我永远不会想到这一点。我去试试

    【讨论】:

      猜你喜欢
      • 2013-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多