0
開關按鈕出現在我的所有其他圖層中,我在想是否有辦法只出現在某個圖層中。我實現了這個聲音,但它也在我的其他圖層中
.h文件中
UISwitch *muteSwitch;
.m文件
muteSwitch = [[ UISwitch alloc ] initWithFrame: CGRectMake(0, 290, 0, 0) ];
muteSwitch.on = YES;
[muteSwitch addTarget:self action:@selector(soundOnOrOff:) forControlEvents:UIControlEventValueChanged];
[[[CCDirector sharedDirector] openGLView] addSubview:muteSwitch];
[muteSwitch release];
- (void)soundOnOrOff:(id)sender
{
if ([[SimpleAudioEngine sharedEngine] mute]) {
// This will unmute the sound
[[SimpleAudioEngine sharedEngine] setMute:0];
}
else {
//This will mute the sound
[[SimpleAudioEngine sharedEngine] setMute:1];
}
}