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

Properties

scaleOnPush

If true, the button does a scaling animation when pushed.

@property (readwrite, assign) bool scaleOnPush

Declared In

Button.h

touchablePortion

The portion of this button that is actually touchable

@property (nonatomic, readwrite, retain) CCNode *touchablePortion

Declared In

Button.h

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

onButtonPressed

Called when a button press is detected. Subclasses can use this method to add behavior to a button push.

- (void)onButtonPressed

Declared In

Button.h

onButtonUp

Called when a button is released. Subclasses can use this method to add behavior to a button push.

- (void)onButtonUp

Declared In

Button.h