2009-11-25 69 views
0

我想使用框架Cocos2D在屏幕上顯示文本。使用框架在屏幕上顯示一些文本Cocos2D

我正在考慮使用draw方法。但我不知道確切的做法。

如果有人能幫助我解決這個問題,我會很高興。

+0

你的意思是可可或http://code.google.com/p/cocos2d-iphone? – progrmr 2009-11-25 04:01:35

回答

0

最簡單的方法是創建一個CCLabelTTF節點並將其添加到場景中。

0

這是一個可行的辦法:

此代碼是一個簡單的場景類別中:

// on "init" you need to initialize your instance 
-(id) init 
{ 
    // always call "super" init 
    // Apple recommends to re-assign "self" with the "super's" return value 
    if((self=[super init])) 
    { 
     // create and initialize a Label 
     CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64]; 

     // ask director for the window size 
     CGSize size = [[CCDirector sharedDirector] winSize]; 

     // position the label on the center of the screen 
     label.position = ccp(size.width /2 , size.height/2); 

     // add the label as a child to this Layer 
     [self addChild: label]; 
    } 
    return self; 
} 

希望它可以幫助你!