详细说明
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)init { 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;
}
答案 0 :(得分:3)
我发现了一条线索和可能的解决方案!看看这个人的代码:
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!我从来没有想过这一点。我要去试试