gpt4 book ai didi

ios - 条件下在其他情况下的预期表达

转载 作者:行者123 更新时间:2023-12-01 18:14:44 26 4
gpt4 key购买 nike

我有以下代码来确定游戏是否应该移动到下一个级别。最后的else if and else条件导致两个错误。 “期望的表达式”和“期望的标识符”。如果我注释掉这些条件,代码可以正常编译。不确定我缺少什么。任何帮助将不胜感激。

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches) {
SKNode *n = [self nodeAtPoint: [touch locationInNode:self]];
if (n !=self && [n.name isEqual:@"restartLabel"] && _gameLevel == 0){
[[self childNodeWithName:@"restartLabel"] removeFromParent];
[[self childNodeWithName:@"winLoseLabel"] removeFromParent];
SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
SKScene * myScene = [[MyScene alloc] initWithSize:self.size];
[self.view presentScene:myScene transition: reveal];
return;
}
else if (n !=self && [n.name isEqual:@"nextLevelLabel"] && _gameLevel == 1)
{
[[self childNodeWithName:@"nextLevelLabel"] removeFromParent];
[[self childNodeWithName:@"winLoseLabel"] removeFromParent];
SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
SKScene * myScene2 = [[MyScene2 alloc] initWithSize:self.size];
[self.view presentScene:myScene2 transition: reveal];
return;
}
}
else if (n !=self && [n.name isEqual:@"nextLevelLabel"] && _gameLevel == 2)
{
[[self childNodeWithName:@"nextLevelLabel"] removeFromParent];
[[self childNodeWithName:@"winLoseLabel"] removeFromParent];
SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
SKScene * myScene3 = [[MyScene3 alloc] initWithSize:self.size];
[self.view presentScene:myScene3 transition: reveal];
return;
}
}
else
{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"End of the Road" message:@"You reached the end of the game. More levels coming soon!" delegate:self cancelButtonTitle:@"Ok" nil]
[alert show];
}
@end

最佳答案

else if (n !=self && [n.name isEqual:@"nextLevelLabel"] && _gameLevel == 1)
{
[[self childNodeWithName:@"nextLevelLabel"] removeFromParent];
[[self childNodeWithName:@"winLoseLabel"] removeFromParent];
SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
SKScene * myScene2 = [[MyScene2 alloc] initWithSize:self.size];
[self.view presentScene:myScene2 transition: reveal];
return;
}
} <--- remove this

关于ios - 条件下在其他情况下的预期表达,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23224561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com