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
-
touchablePortionThe portion of this button that is actually touchable
property -
scaleOnPushIf true, the button does a scaling animation when pushed.
property -
+ buttonWithTouchablePortion:target:selector:Create a new button.
-
– initWithTouchablePortion:target:selector:Initialize a button.
-
– onButtonPressedCalled when a button press is detected. Subclasses can use this method to add behavior to a button push.
-
– onButtonDownCalled when a button is pushed down. Subclasses can use this method to add behavior to a button push.
-
– onButtonUpCalled 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)selectorParameters
- 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.hInstance Methods
initWithTouchablePortion:target:selector:
Initialize a button.
- (id)initWithTouchablePortion:(CCNode *)node target:(id)target selector:(SEL)selectorParameters
- 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.honButtonDown
Called when a button is pushed down. Subclasses can use this method to add behavior to a button push.
- (void)onButtonDownDeclared In
Button.h