请告诉我,如何写一个按钮标签?我有这样的代码:
CCMenuItem *Podskazki = [CCMenuItemImage
itemFromNormalImage:@"button.png" selectedImage:@"button1.png" target:self selector:@selector(menuCallbackPodskazki:) ];
CCMenu *ButtonPodskazki =[CCMenu menuWithItems:Podskazki, nil];
[ButtonPodskazki alignItemsHorizontallyWithPadding:20];
[ButtonPodskazki setPosition:ccp(-Podskazki.contentSize.width/2+size.width,Podskazki.contentSize.height/2)];
[self addChild:ButtonPodskazki];
答案 0 :(得分:0)
在菜单项中添加标签。
CCMenuItem * Podskazki = [CCMenuItemImage
itemFromNormalImage:@"button.png" selectedImage:@"button1.png" target:self selector:@selector(menuCallbackPodskazki:) ];
CCLabelTTF *label = [[CCLabelTTF alloc] initWithString:@"string" fontName:@"font" fontSize:14.0f];
CGSize size = item.boundingBox.size;
label.position = ccp(size.width / 2.0f, size.height / 2.0f);
[Podskazki addChild:label];
答案 1 :(得分:0)
CCMenu *m = [CCMenu menuWithItems:i, nil];
m.position = ccp(0,0);
[l addChild:m];
//Play next
CCSprite *sp = [CCSprite spriteWithSpriteFrameName:@"friend_letter.png"];
CCLabelTTF *lb = [CCLabelTTF labelWithString:NSLocalizedString(@"Tell a friend", nil) fontName:@"42835" fontSize:12];
sp.position = ccp(lb.contentSize.width/2,lb.contentSize.height/2+30);
[lb addChild:sp];
CCMenuItemLabel *i = [CCMenuItemLabel itemWithLabel:lb target:self selector:@selector(continueAction)];
[i setContentSize:CGSizeMake(MAX(44, i.contentSize.width), MAX(60, i.contentSize.height))];
i.position = ccp(100,100);
[m addChild:i];