2011-02-22 40 views
1

嘿,我瘋了堅持這一點。我想用我酷酷的heiro字體表,我把CCLabelBMFont當作標籤和評分變量使用,但是無法將它們作爲可點擊項目進入菜單!但它的CCLabelMBFont說特別,你可以用它們作爲菜單項 - 在這裏看到:CCLabelBMFont爲菜單項?

詳細說明

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((自我= [超級的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; 

}

回答

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!我從來沒有想過這件事。我要去試試