2012-08-08 69 views
0

我正在創建一個iphone應用程序,出於某種原因,當我運行代碼時,指令不會出現。這是我的指導課。當我運行程序時,什麼也沒有顯示出來。Instructions.m(遊戲說明)未打印出說明?

不應該「該遊戲的對象是」顯示在屏幕上?

謝謝你力所能及的幫助/知識,你可以提供給我:)

#import "Instructions.h" 
#import "MainMenu.h" 

@implementation Instructions 

+ (CCScene *) scene 
{ 
    CCScene * scene = [CCScene node]; // scene is an autorelease object 
    Instructions * layer = [Instructions node]; // later is an autorelease object 
    [scene addChild: layer]; // add layer as a child to scene 
    return scene; // return the scene 
} 

- (id) init 
{ 
    if ((self = [super init])) 
    { 
     [ self how ]; 
    } 
    return self; 
} 

- (void) how 
{ 
    NSLog(@"The object of this game is "); 
} 
@end 

回答

0

NSLog不會在屏幕上什麼都沒有。它只是在Xcode的控制檯中打印文本。

要在屏幕上顯示文字,請嘗試製作標籤。就像這樣:

- (void) how 
{ 
    // Create the label 
    CCLabelTTF *label = [CCLabelTTF labelWithString:@"The object of this game is..." fontName:@"Arial" fontSize:30]; 

    // Position it on the screen 
    label.position = ccp(160,240); 

    // Add it to the scene so it can be displayed 
    [self addChild:label z:0]; 
} 

更多關於標籤:http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:labels