【发布时间】:2014-03-15 22:17:21
【问题描述】:
所以我创建了一个 SKLabelNode: 编辑:将代码更改为: //。H {SKLabelNode *PausedLabel22;} //.m PausedLabel22= [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"]; PausedLabel22.text = @"游戏暂停"; PausedLabel22.fontSize = 30; PausedLabel22.fontColor = [SKColor blackColor]; PausedLabel22.position = CGPointMake(160, 340); //[self addChild:PausedLabel22]; 这曾经非常好,但后来我有了我的方法:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (paused == YES) {
paused = NO;
[PausedLabel22 removeFromParent];
NSLog(@"UnPaused");
}else if (touchLocation.x > self.frame.size.width - 80 && touchLocation.y > self.size.height-80 && touchLocation.y < self.size.height-40) {
paused = YES;
NSLog(@"Paused");
//PausedLabel22.text = [NSString stringWithFormat:@"Game Paused"];
//PausedLabel22.fontColor = [SKColor blackColor];
//PausedLabel22.position = CGPointMake(160, 320);
[self addChild:PausedLabel22];
}
NSLog(@"Text Postion: (%f, %f)", PausedLabel22.position.x, PausedLabel22.position.y);
NSLog(@"Text: %@", PausedLabel22.text);
NSLog(@"Text color: %@", PausedLabel22.fontColor);
我的日志显示: 2014-03-15 23:12:12.734 核游戏[1418:60b] 未暂停 2014-03-15 23:12:12.735 NuclearGame[1418:60b] 文字位置:(160.000000, 320.000000) 2014-03-15 23:12:12.736 NuclearGame[1418:60b] 文字:游戏暂停 2014-03-15 23:12:12.737 NuclearGame[1418:60b] 文本颜色:UIDeviceRGBColorSpace 0 0 0 0 2014-03-15 23:12:13.248 核游戏[1418:60b] 暂停 2014-03-15 23:12:13.251 NuclearGame[1418:60b] 文字位置:(160.000000, 320.000000) 2014-03-15 23:12:13.252 NuclearGame[1418:60b] 文本:游戏暂停 2014-03-15 23:12:13.254 NuclearGame[1418:60b] 文本颜色:UIDeviceRGBColorSpace 0 0 0 1
但是,标签会出现在屏幕上(因为它在开始时被调用)然后消失得很好,但永远不会重新出现在屏幕上!
编辑:标签仍然没有出现......
【问题讨论】:
标签: ios iphone sprite-kit sklabelnode