Game Development Reference
In-Depth Information
2x, or you can design them with a 56x20-pixel resolution and not worry about changing
the
Scale from
setting.
Connecting the Sliders
This should be almost second nature by now: Select the effects slider and switch to the
Item Code Connections
tab. Enter
volumeDidChange:
in the
Selector
field, and check the
Continuous
check box. Also enter
_effectsSlider
in the
Doc root var
field.
Repeat this for the music slider: set its
Selector
to
volumeDidChange:
, also check the
Continuous
check box, and then enter
_musicSlider
in the
Doc root var
field.
Yes, both sliders use the same selector. Also note the trailing colon in both selectors—if
there's a colon at the end of a selector, the method receives a parameter. The
CCControl
class that sends these selectors supports sending parameterless methods, as you've used
before, as well as methods with a single parameter, as in this case. The parameter is al-
ways the
CCControl
object running the selector—in this case, the CCSlider instances.
I'll say more on this shortly.
What's missing? The custom class for the root node of course! Select the root node, and
enter
SettingsLayer
in the
Custom class
field.
Now you can move over to Xcode and create the
SettingsLayer
class in the
Source
Edit
SettingsLayer.h
to add a property that holds a reference to a
MainMenuButtons
header file in the
SettingsLayer.h
header file—something you should strive to avoid when
possible.
Listing 7-3
.
The SettingsLayer interface
#import "CCNode.h"
@class MainMenuButtons;
@interface SettingsLayer : CCNode
@property (weak) MainMenuButtons* mainMenuButtons;
@end
SettingsLayer.m
needs the additions highlighted in
Listing 7-4
.
Search WWH ::
Custom Search