Вопрос

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