我正在创建一个iphone应用程序,由于某些原因,当我运行代码时,指令不会出现。这是我的instructions类。当我运行程序时,什么也没有显示。
“这个游戏的目标是”不应该出现在屏幕上吗?
感谢您能为我提供的一切帮助/知识:)
#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发布于 2012-08-09 04:25:00
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
https://stackoverflow.com/questions/11872127
复制相似问题