Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Spritekit swift中,它写道:预期声明_Ios_Swift_Sprite Kit - Fatal编程技术网

Ios 在Spritekit swift中,它写道:预期声明

Ios 在Spritekit swift中,它写道:预期声明,ios,swift,sprite-kit,Ios,Swift,Sprite Kit,我正在用SpriteKit swift编程,突然我听到一个错误,说 “预期声明” 下面是我得到错误的代码: for touch in touches { print(touch) } func Enemies(){ print("enemies") } override func update(currentTime: CFTimeInterval) { /* Called before

我正在用SpriteKit swift编程,突然我听到一个错误,说

“预期声明”

下面是我得到错误的代码:

    for touch in touches {
            print(touch)
        }

    func Enemies(){
        print("enemies")
    }

    override func update(currentTime: CFTimeInterval) {
        /* Called before each frame is rendered */
    }
}

这是因为您不能在任何地方声明for语句。您很可能需要将其放入
touchesbeated
方法。

我使用了此代码,但没有得到错误。请再给我看看。你很可能在某个地方丢失了一个括号或圆括号。我刚刚更新了它,现在你可以检查它。错误发生在哪里?在触摸中的触摸{