切り替えボタンは他のすべてのレイヤーに表示されますが、特定のレイヤーにのみ表示する方法があるかどうか疑問に思っていました。
.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];
}
}