Bagusflyer
Bagusflyer

Reputation: 12925

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

Upvotes: 15

Views: 4595

Answers (2)

TwoStraws
TwoStraws

Reputation: 13127

Although other solutions are generally preferred, future readers might like to know that performSelector and other members of the same family are available as of Swift 2.

Upvotes: 0

John Estropia
John Estropia

Reputation: 17500

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
    }
}

Upvotes: 16

Related Questions