Game Development Reference
In-Depth Information
Figure 6-3
.
CCButton properties with proper title and custom graphics
When selected,
Zoom when highlighted
will zoom in the button (both background and la-
bel) when the user taps and holds. This is a legacy feature because Cocos2D used to do
that to all menu buttons, for better or worse. I think it's a crude effect, so try to avoid it.
Instead, I'll shortly explain neat tricks with which you can give the user visual cues
without resorting to zooming or changing the background image.
Checking
Toggles selected state
makes the button a toggle button, changing from its nor-
mal state to its selected state and back every time it is tapped. When the button is in the
selected state, the properties for the
Selected State
section are used. So if you want to
make a toggle button, be sure to use different properties for
Normal State
and Selected
State; otherwise, you won't be able to tell whether the button is on or off, normal or selec-
ted.
The
Normal State
section in the bottom half of
Figure 6-3
is representative of all of the
button's possible state properties. All button states have the same
Sprite frame
,
Back-
ground
, and
Label
properties. There are four button states:
Normal:
The default state.
Highlighted:
Takes effect for the duration the button is touched (tap and
hold).
Disabled:
In effect when the button's
enabled
property is set to
NO
pro-
grammatically or by adding a custom property (see Tip box that follows) to
signal that the button currently does not function.
Search WWH ::
Custom Search