Game Development Reference
In-Depth Information
Listing 7-4 . The slider selectors receive the sender as an input parameter
#import "SettingsLayer.h"
#import "MainMenuButtons.h"
@implementation SettingsLayer
{
__weak CCSlider* _musicSlider;
__weak CCSlider* _effectsSlider;
}
-(void) volumeDidChange:(CCSlider*)sender
{
NSLog(@"volume changed, sender: %@", sender);
}
@end
The sender parameter is always of type CCControl* , but since you can be certain
that only sliders run this selector, you can safely assume the parameter to be of type
CCSlider*. CCSlider is, of course, a subclass of CCControl . The two
CCSlider ivars will be used to determine which slider performed the
volumeDidChange: selector.
Before you can try out the sliders, you need to load and show the settings layer in
MainMenuButtons.m . Specifically, replace the existing shouldShowSettings method
with the one in Listing 7-5 .
Listing 7-5 . Show the settings layer
-(void) shouldShowSettings
{
SettingsLayer* settingsLayer
= (SettingsLayer*)[CCBReader load:
@"UserInterface/
SettingsLayer"];
settingsLayer.mainMenuButtons = self;
[self.parent addChild:settingsLayer];
self.visible = NO;
}
Search WWH ::




Custom Search