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).

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top