Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top