小编Dam*_*ant的帖子

如果条件,则预期在else上表达

我有以下代码来确定游戏是否应该进入下一个级别.最后一个if和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 …
Run Code Online (Sandbox Code Playgroud)

if-statement ios

1
推荐指数
1
解决办法
2734
查看次数

标签 统计

if-statement ×1

ios ×1