@@ -76,6 +76,10 @@ - (instancetype)init
76
76
77
77
[self serveFromSide: PaddleSideInvalid];
78
78
79
+ // set effects volume
80
+ NSUserDefaults *setup = [NSUserDefaults standardUserDefaults ];
81
+ [OALSimpleAudio sharedInstance ].effectsVolume = [setup floatForKey: kGameKeySoundVolume ];
82
+
79
83
return self;
80
84
}
81
85
@@ -176,6 +180,8 @@ - (void)update:(CCTime)delta
176
180
// check for paddle-ball collisions
177
181
if (CGRectIntersectsRect (_paddleA.rect , _ball.rect ))
178
182
{
183
+ // da beep
184
+ [[OALSimpleAudio sharedInstance ] playEffect: @" beep.wav" ];
179
185
// adjust ball position
180
186
_ball.position = (CGPoint){_paddleA.position .x + ((_paddleA.contentSize .width + _ball.contentSize .width ) * 0.5 ), _ball.position .y };
181
187
// change direction
@@ -191,6 +197,8 @@ - (void)update:(CCTime)delta
191
197
}
192
198
else if (CGRectIntersectsRect (_paddleB.rect , _ball.rect ))
193
199
{
200
+ // da beep
201
+ [[OALSimpleAudio sharedInstance ] playEffect: @" beep.wav" ];
194
202
// adjust ball position
195
203
_ball.position = (CGPoint){_paddleB.position .x -((_paddleB.contentSize .width + _ball.contentSize .width ) * 0.5 ), _ball.position .y };
196
204
// change direction
@@ -204,13 +212,17 @@ - (void)update:(CCTime)delta
204
212
// check for paddle top and bottom collision
205
213
if (_ball.position .y < (_ball.contentSize .height * 0.5 ))
206
214
{
215
+ // da beep
216
+ [[OALSimpleAudio sharedInstance ] playEffect: @" beep.wav" ];
207
217
// adjust ball position
208
218
_ball.position = (CGPoint){_ball.position .x , _ball.contentSize .height * 0.5 };
209
219
// change direction
210
220
_ballVector.y = -_ballVector.y ;
211
221
}
212
222
else if (_ball.position .y > (_gameSize.height - (_ball.contentSize .height * 0.5 )))
213
223
{
224
+ // da beep
225
+ [[OALSimpleAudio sharedInstance ] playEffect: @" beep.wav" ];
214
226
// adjust ball position
215
227
_ball.position = (CGPoint){_ball.position .x , _gameSize.height - (_ball.contentSize .height * 0.5 )};
216
228
// change direction
@@ -220,6 +232,8 @@ - (void)update:(CCTime)delta
220
232
// check for score
221
233
if (_ball.position .x < -(_ball.contentSize .width * 0.5 ))
222
234
{
235
+ // da beep
236
+ [[OALSimpleAudio sharedInstance ] playEffect: @" game.wav" ];
223
237
// paddle B scored
224
238
225
239
@@ -229,6 +243,8 @@ - (void)update:(CCTime)delta
229
243
}
230
244
else if (_ball.position .x > (_gameSize.width + (_ball.contentSize .width * 0.5 )))
231
245
{
246
+ // da beep
247
+ [[OALSimpleAudio sharedInstance ] playEffect: @" game.wav" ];
232
248
// paddle A scored
233
249
234
250
0 commit comments