Button Class Reference
Inherits from | TouchableNode : CCNode : NSObject |
Conforms to | CCRGBAProtocol |
Declared in | Button.h |
Overview
A button is a touchable node that sends a message back to a listener when touched and released. Note: It will only trigger if both the touch and release occur within the active area (rectangle defined by the button’s position and the touchable portion’s contentSize).
Tasks
-
touchablePortion
The portion of this button that is actually touchable
property -
scaleOnPush
If true, the button does a scaling animation when pushed.
property -
+ buttonWithTouchablePortion:target:selector:
Create a new button.
-
– initWithTouchablePortion:target:selector:
Initialize a button.
-
– onButtonPressed
Called when a button press is detected. Subclasses can use this method to add behavior to a button push.
-
– onButtonDown
Called when a button is pushed down. Subclasses can use this method to add behavior to a button push.
-
– onButtonUp
Called when a button is released. Subclasses can use this method to add behavior to a button push.
Properties
Class Methods
buttonWithTouchablePortion:target:selector:
Create a new button.
+ (id)buttonWithTouchablePortion:(CCNode *)node target:(id)target selector:(SEL)selector
Parameters
- node
the node to use as a touchable portion.
- target
the target to notify when the button is pressed.
- selector
the selector to call when the button is pressed.
Return Value
a new button.
Declared In
Button.h
Instance Methods
initWithTouchablePortion:target:selector:
Initialize a button.
- (id)initWithTouchablePortion:(CCNode *)node target:(id)target selector:(SEL)selector
Parameters
- node
the node to use as a touchable portion.
- target
the target to notify when the button is pressed.
- selector
the selector to call when the button is pressed.
Return Value
the initialized button.
Declared In
Button.h
onButtonDown
Called when a button is pushed down. Subclasses can use this method to add behavior to a button push.
- (void)onButtonDown
Declared In
Button.h