1

I am new to sounds in Xcode and I wish to play a sound repeatedly, whether it is playing already or not. Eg. I have three lasers which are being shot, and I wish for the laser sound to be played three times simultaneously, without waiting for each one to finish playing. How do I achieve this using AVAudioPlayer?

1 Answer 1

0

Do this:

AVAudioPlayer *laserSound1  = .........
laserSound1.numberOfLoops = 2; //plays three times simultaneously
[laserSound1 play];

 AVAudioPlayer *laserSound2  = .........
laserSound2.numberOfLoops = 2;//plays three times simultaneously
[laserSound2 play];

AVAudioPlayer *laserSound3  = .........
laserSound3.numberOfLoops = 2;//plays three times simultaneously
[laserSound3 play];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.