Swift

Swift Detect Node Overlap

Detect if nodes overlap
if enemy.contains((car.position)) {
// code
}

Audio with Swift

Audio
Add audio delegate
Pasted Graphic 1
Create audioPlayer public variable
Pasted Graphic
Create music function
Pasted Graphic 2
To prevent below error on play, be sure Music0.m4a is added to Build Phases
Pasted Graphic 4
https://stackoverflow.com/questions/41775563/bundle-main-pathforresourceoftypeindirectory-returns-nil
Pasted Graphic 3

Swift Nil Check

Useful Nil Name Check

// verify name not nil
if ((node.name?.isEmpty) != nil) {
// exclude already clicked items
// only player circle
if node.name == "player" {
// change node position
node.position = location

//turn off player gravity field
let player = childNodeWithName("player") as! SKShapeNode
player.physicsBody?.dynamic = false
player.physicsBody!.fieldBitMask = PhysicsCategory.player
player.physicsBody?.dynamic = true
}
}