Objective-C sound effect

hello everybody ,

I want to add a sound effect when a collision happens, for instance :

when the bird.frame touch the topcolumn , bottomcolumn or the ground.frame , I want to add a sound effect (It's a mp3 file during 1 sec)

Don't capitlize method names in ObjC. Renamed GameOver to gameOver.


You can use AVAudioPlayer h t t p s://developer.apple.com/reference/avfoundation/avaudioplayer


There also is the AudioToolbox framework.

if (CGRectIntersectsRect(bird.frame, topcolumn.frame)) {

[self Gameover];

scorenumber = 0;

// I want the song effect to play here

}

if (CGRectIntersectsRect(bird.frame, bottomcolumn.frame)) {

[self Gameover];

scorenumber = 0;

// I want the song effect to play here

}

if (CGRectIntersectsRect(bird.frame, ground.frame)) {

[self Gameover];

scorenumber = 0;

// I want the song effect to play here

}

Accepted Answer

Don't capitlize method names in ObjC. Renamed GameOver to gameOver.


You can use AVAudioPlayer h t t p s://developer.apple.com/reference/avfoundation/avaudioplayer


There also is the AudioToolbox framework.

Thank you very much for you help!

Objective-C sound effect
 
 
Q