Group Group Group Group Group Group Group Group Group

Breaker: sequenced actions vs action closures

#1

I personally find closure’s hard to read. I’m talking about the closure waitForDurationThenRunBlock(duration:120) when processing the balls collision with a brick.

Instead I added these properties to the class:
let hideBrick = SCNAction.hide()
let wait2Minutes = SCNAction.wait(duration: 120)
let showBrick = SCNAction.unhide()

Then in physicsWorld(_:didBegin:):
switch contactNode.physicsBody?.categoryBitMask {
case ColliderType.brick.rawValue:
game.score += 1
contactNode.runAction(.sequence([hideBrick, wait2Minutes, showBrick]))

So my question is, is there a performance hit for writing the code this way?

Thanks in advance! Love the book. Also I wish you guys would do more tutorials on macOS programming.

#2

@chrislanguage Can you please help with this when you get a chance? Thank you - much appreciated! :]

closed #3

This topic was automatically closed after 166 days. New replies are no longer allowed.