Hi everybody i have this piece of code
i have this button called botonMuteOn which is kind of a speaker. It mutes the music and i'd like this to be replaced by a new button with the sprite mute2 that plays the music back again
but something's not working with the removeChild
any ideas of what's wrong?
thankyou
@implementation MainMenuLayer
- (id) init {
self = [super init];
if (self != nil) {
//music
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"mainSoundtrack.mp3"];
//mute
CCMenuItem *mute = [CCMenuItemImage itemFromNormalImage:@"mute1.png"
selectedImage:@"mute1.png"
target:self
selector:@selector(muteOn:)];
botonMuteOn = [CCMenu menuWithItems: mute, nil];
botonMuteOn.position =ccp(30, 30);
[self addChild: botonMuteOn];
}
return self;
}
//functions
-(void)muteOn:(id)sender {
[[SimpleAudioEngine sharedEngine] stopBackgroundMusic];
[MainMenuLayer removeChild:botonMuteOn Cleanup:YES];
CCMenuItem *muteOn = [CCMenuItemImage itemFromNormalImage:@"muteOn.png"
selectedImage:@"muteOn.png"
target:self
selector:@selector(muteOff:)];
CCMenu *botonMuteOff = [CCMenu menuWithItems: muteOn, nil];
botonMuteOff.position =ccp(30, 30);
[self addChild: botonMuteOff];
}
@end