所以我在游戏中添加了一个暂停按钮,冻结和解冻视图。但是我想让它显示一条消息,说明" PAUSE"如果视图当前已冻结,则在屏幕上显示。但如果我触摸暂停按钮,它就不会显示标签。这真的很奇怪,因为我发现如果我将我的设备转为横向模式,那么" PAUSE"消息出现。 (反之亦然,所以如果我在横向模式下触摸按钮并将我的设备变为肖像,则会出现暂停标签)
有人可以解决这个问题吗?
-(void)gameScene{
//Pause
pauseButton = [SKSpriteNode spriteNodeWithImageNamed:@"pause.jpg"];
pauseButton.position = CGPointMake(screenWidth/2, screenHeight-80);
pauseButton.zPosition = 5;
pauseButton.name = @"pauseButton";
pauseButton.size = CGSizeMake(80, 80);
[self addChild:pauseButton];
//Pause Label (wenn Pause gedrückt wird)
pauseLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
pauseLabel.text = @"PAUSE";
pauseLabel.fontSize = 70;
pauseLabel.position = CGPointMake(screenWidth/2, screenHeight/2);
pauseLabel.zPosition = 5;
pauseCount = 1;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//Pause Button
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if ([node.name isEqualToString:@"pauseButton"]) {
pauseCount++;
if (pauseCount%2 == 0) {
self.scene.view.paused = YES;
[self addChild:pauseLabel];
}
else{
self.scene.view.paused = NO;
[pauseLabel runAction:remove];
}
}
}