Xcode 6 Swift:错误" Gamescene没有名为' spawnBlocks'""

时间:2015-01-01 23:14:18

标签: swift xcode6

好的,我在Swift工作,我将spawnBlocks初始化为函数,但我收到了错误:" Gamescene没有名为' spawnBlocks&#39的成员;"

我看了一些关于SO的其他问题,但他们似乎没有解决这个具体问题。我不知道怎么写这个。代码:

    let spawn = SKAction.runBlock({() in self.spawnBlocks()}) //Error occurs on this line
    let delay = SKAction.waitForDuration(NSTimeInterval(2))
    let spawnThenDelay = SKAction.sequence([spawn, delay])
    let spawnThenDelayForever = SKAction.repeatActionForever(spawnThenDelay)

    self.runAction(spawnThenDelayForever)

    func spawnBlocks() {
        let blockPair = SKNode()
        blockPair.position = CGPointMake(self.frame.size.width + block1Texture.size().width * 2, 0) //change to height
        blockPair.zPosition = -10 //zposition = in front of or in back of, other objects are at 0
    }
}

0 个答案:

没有答案