Cocos2d iphone 菜单项的CCLabelBMFont?
嘿,我被这个迷住了。我想用我很酷的heiro字体表,我得到的CCLabelBMFont作为标签和分数变量工作得很好,但不能将它们作为可点击的项目进入菜单!但是CCLabelMBFont特别指出,您可以将它们用作菜单项--请参见此处: 详细说明 CCLabelBMFont是CCSpriteBatchNode的一个子类 特点:Cocos2d iphone 菜单项的CCLabelBMFont?,cocos2d-iphone,Cocos2d Iphone,嘿,我被这个迷住了。我想用我很酷的heiro字体表,我得到的CCLabelBMFont作为标签和分数变量工作得很好,但不能将它们作为可点击的项目进入菜单!但是CCLabelMBFont特别指出,您可以将它们用作菜单项--请参见此处: 详细说明 CCLabelBMFont是CCSpriteBatchNode的一个子类 特点: * Treats each character like a CCSprite. This means that each individual character can
* 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)init
{
if((self=[super init])){
}我找到了线索和可能的解决方案!请查看以下代码:
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!我永远也想不到。我要试试
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);