【问题标题】:Instructions.m (instructions for the game) are not printing out the instructions?Instructions.m(游戏说明)没有打印出说明?
【发布时间】:2012-08-08 19:51:51
【问题描述】:

我正在创建一个 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

【问题讨论】:

    标签: cocos2d-iphone init nslog


    【解决方案1】:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      相关资源
      最近更新 更多