0

フレームワークを使って画面にテキストを表示したいCocos2D

方法を考えていdrawます。しかし、私はそれを行う正確な方法を知りません。

誰かがこのトピックについて私を助けてくれたらうれしいです。

4

2 に答える 2

0

最も簡単な方法は、CCLabelTTFノードを作成してシーンに追加することです。

于 2011-01-08T01:16:51.577 に答える
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;
}

それがあなたを助けることを願っています!

于 2012-10-02T18:10:15.443 に答える