We have added all the sound effects files to our project previously, so what we are going to do now is just add some code to play them. We need to add the code in three places: when the arrow hits the bird, when we lose, and when we win the game.
Let's start making changes by performing the following steps:
Open the
Bird.m
file and import theAudioManager.h
header file at the top as follows:#import "AudioManager.h"
Next, find the
removeBird:
method and add the corresponding sound effect that will be played when the bird is hit by an arrow:-(int)removeBird:(BOOL)hitByArrow { //..skipped if (hitByArrow) { //..skipped.. [[AudioManager sharedAudioManager] playSoundEffect:@"bird_hit.mp3"]; } //..skipped.. }
The final file we...