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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top