2009-11-25 5 views
0

Je souhaite afficher un texte à l'écran en utilisant le cadre Cocos2D. Je pense à utiliser la méthode draw. Mais je ne connais pas la façon exacte de le faire.Affichage de texte à l'écran à l'aide du cadre Cocos2D

Je serais heureux si quelqu'un pouvait m'aider sur ce sujet.

+0

Voulez-vous dire Cocoa ou http://code.google.com/p/cocos2d-iphone? – progrmr

Répondre

0

Le moyen le plus simple serait de créer un nœud CCLabelTTF et de l'ajouter à votre scène.

0

Voici un moyen possible:

Ce code est dans une classe simple scène:

// 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; 
} 

L'espoir peut vous aider!

Questions connexes