I'm trying to achieve the following
- User presses a CCMenuItem
- Play sound file (I set it as background music so I can check if it is playing)
- Disable touch on all CCMenuItem's
- Wait for sound file to complete playing
- Upon completion of sound file reenable touch on all CCMenuItems
The function I'm using to wait in my model does the following:
- (void) waitForAudio
{
while ([[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying]) {
NSLog(@"Waiting for audio to finish");
}
}
My view has the following function:
-(void) setPlaygroundAsTouchable:(BOOL)touchable
{
[_menuItem0 setIsEnabled:touchable];
[_menuItem1 setIsEnabled:touchable];
[_menuItem2 setIsEnabled:touchable];
_menu.isTouchEnabled=touchable;
}
The controller calls and sets the view function when my model starts and ends a sound file NO and YES respectively.
The problem i'm facing is, the touches on my CCMenuItems seems to be queued up during the playing of my audio- which means each touch is registered and processed when the sound file is completed. Is there a way for me to stop touches from queueing up whilst my waitForAudio function is still looping?