SKLabelNode未显示在屏幕上

时间:2014-01-26 21:46:01

标签: ios sprite-kit

在私人界面

   @property BOOL contentCreated

然后在实施中

//just like in Apple's example project

- (void)didMoveToView: (SKView *) view {
   if (!self.contentCreated) {
       [self createSceneContents];
       self.contentCreated = YES;
   }
}

- (void)createSceneContents {
    self.backgroundColor = [SKColor whiteColor];
    self.scaleMode = SKSceneScaleModeAspectFill;
    SKLabelNode *newGameNode = [[SKLabelNode alloc] initWithFontNamed:
        @"Helvetica"];
    newGameNode.name = @"NewGame";
    newGameNode.text = @"New Game";
    newGameNode.fontSize = 30;
    newGameNode.fontColor = [SKColor whiteColor];
    newGameNode.position = CGPointMake(100, 100);
    [self addChild:newGameNode];
}

但是当我跑步时,屏幕上没有任何内容。我做错了什么?

1 个答案:

答案 0 :(得分:6)

这是因为您在白色背景上显示白色文字。试试这个:

newGameNode.fontColor = [SKColor blackColor];