Swift中SKAction中performSelector的替代方法

Bag*_*yer 15 objective-c ios sprite-kit swift

我正在将Sprikit应用程序转换为Swift.但我转换此方法有问题:

SKAction *releaseBalls = [SKAction sequence:@[[SKAction performSelector:@selector(createMyNode) onTarget:self],[SKAction waitForDuration:1]    ]];
Run Code Online (Sandbox Code Playgroud)

Swift中有替代代码吗?谢谢

Joh*_*pia 16

试试吧

class MyScene: SKScene {

    func doAction() {
        let releaseBalls = SKAction.sequence([
            SKAction.runBlock(self.createMyNode),
            SKAction.waitForDuration(1)
            ])
        // run action
    }

    func createMyNode() {
        // create the nodes
    }
}
Run Code Online (Sandbox Code Playgroud)