Question

I'm using Apple's Sprite Kit Framework and I'm wondering how I can attach a sound file to an SKEmitterNode such that every time a particle is emitted, it plays the sound.

EG: A gun shooting bullets with a bang each time the bullet (particle) is fired (emitted).

Was it helpful?

Solution

To achieve desired effect you can use particleAction property on the emitter to define sound playing action.

Define sound playing action using SKAction playSoundFileNamed:waitForCompletion: or play sound inside a block and run it using SKAction runBlock:

Action will run every time particle is emitted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top