Game Development Reference
In-Depth Information
Selected:
Used when
Toggles selected state
is checked and the button has
been tapped once, and for every other tap following that.
Tip
The
Disabled
state does not correspond to the
User Interaction Enabled
check box, and you can't edit the
enabled
property in SpriteBuilder. Unless
you want to add a custom property to the button, name it
enabled
, and set its
type to
Bool
and its value to
0
. Alas, you can't add custom properties unless
you specify a
Custom class
on the
Item Code Connections
tab. But who is to
say this class has to be a truly
custom
class?
As a matter of fact, you can enter a node's original class (here:
CCButton
) as
provided by Cocos2D in the
Custom class
field to make the
Edit Custom Prop-
erties
button appear at the bottom of the
Item Properties
tab. Then you can add
any of the class'
Bool
,
Int
,
Float
, and
String
properties that are not nor-
mally editable in SpriteBuilder.
In this case, the button uses only the
Normal
and
Highlighted
states. Click on the
Sprite
frame
drop-down menu and select
SpriteSheets/UserInterface/P_exit.png
when using the
topic's graphics. Do so for both normal and highlighted
sprite frame
properties.
When using your own graphics, just make sure the sprite frame is set to the same image
for both states.
To give the user a visual cue that she is currently touching the button, it suffices to change
the
Background opacity
and
Label opacity
of the normal state to a value slightly below
1.0, say 0.8. This makes the button slightly transparent and only becoming fully opaque
when touching it.
Another option for a visual highlight is to leave both normal and highlighted state settings
at their default values except for one or both color properties of either the normal or high-
lighted state. The button's background and/or label would then change color when high-
lighted—for instance, lit up with a bright white as opposed to a light gray in the normal
state. In this instance, that effect is also used by making the button's
Label color
a light
gray in the normal state.
Tip
When using colors for highlights, the best effects are achieved with only
subtle color variations. For instance, you could use lighter and darker versions
of the same color. Changing the background or label color from green to
red...well, that's just going to look ugly.
Search WWH ::
Custom Search