Instructions.m(游戏说明)没有打印出说明书?

时间:2012-08-08 19:51:51

标签: cocos2d-iphone init nslog

我正在创建一个iphone应用程序,出于某种原因,当我运行代码时,指令不会出现。这是我的指导课。当我运行程序时,没有任何显示。

屏幕上是否应显示“此游戏的对象”?

感谢您提供给我的任何帮助/知识:)

#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

1 个答案:

答案 0 :(得分: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