Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative method for performSelector in SKAction in Swift

I'm converting a Sprikit App to Swift. But I have a problem to convert this method:

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

Is there any alternative code in Swift ? Thanks

like image 237
Bagusflyer Avatar asked Jun 10 '14 01:06

Bagusflyer


1 Answers

Try this out

class MyScene: SKScene {

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

    func createMyNode() {
        // create the nodes
    }
}
like image 128
John Estropia Avatar answered Oct 22 '22 23:10

John Estropia