Lalit Prabhu
Lalit Prabhu

Reputation: 73

How to send signals for events in SpriteKit games in a single scene?

I want to change the background music after a specific event in the same scene. Do I have to use Booleans and update() function or is there a way to do delegation in a single scene?

Sample code would be appreciated. Any advice on how to properly ask these type of questions on stackoverflow would be nice.

Upvotes: 0

Views: 85

Answers (1)

Zeotyn
Zeotyn

Reputation: 56

You can try the SKAction methods.

An example:

override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
   self.runAction(SKAction.playSoundFileNamed("filename.type"), waitForCompletion: false))
}

With this action, u play a sound on toucheEnded, but you can use it everywhere u need a sound.

Upvotes: 1

Related Questions