Inherits from NSObject
Declared in CCResponder.h

Overview

CCResponder is the base class for all nodes. It exposes the touch and mouse interface to any node, which enables user interaction.

To make a responder react to user interaction, the touchesXXX / mouseXXX event must be overridden. If this is not the case, the event will be passed on to the next responder. To force the events to be passed to next responder, call the super as last step, before returning from the event.

Properties

claimsUserInteraction

Locks the touch to the node if touch moved outside If a node claims user interaction, the touch will continue to be sent to the node, no matter where the touch is moved If the node does not claim user interaction, a touch will be cancelled, if moved outside the nodes detection area If the node does not claim user interaction, and a touch is moved from outside the nodes detection area, to inside, a touchBegan will be generated.

@property (nonatomic, assign) BOOL claimsUserInteraction

Declared In

CCResponder.h

exclusiveTouch

All other touches will be cancelled / ignored, if a node with exclusive touch, is active Only one exclusive touch can be active at a time.

@property (nonatomic, assign, getter=isExclusiveTouch) BOOL exclusiveTouch

Declared In

CCResponder.h

hitAreaExpansion

Expands ( or contracts ) the hit area of the node. The expansion is calculated as a margin around the sprite, in points.

@property (nonatomic, assign) float hitAreaExpansion

Declared In

CCResponder.h

multipleTouchEnabled

Enables multiple touches inside a single node.

@property (nonatomic, assign, getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled

Declared In

CCResponder.h

userInteractionEnabled

Enables user interaction on a node.

@property (nonatomic, assign, getter=isUserInteractionEnabled) BOOL userInteractionEnabled

Declared In

CCResponder.h

Instance Methods

hitTestWithWorldPos:

Check if a touch is inside the node. To allow for custom detection, override this method.

- (BOOL)hitTestWithWorldPos:(CGPoint)pos

Parameters

pos

World position.

Return Value

Returns true, if the position is inside the node.

Declared In

CCResponder.h

init

Initialzes a new CCResponder.

- (id)init

Return Value

An CCResponder CCLabelBMFont Object.

Declared In

CCResponder.h

mouseDown:

Called when left mouse button is pressed inside a node accepting user interaction.

- (void)mouseDown:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

mouseDragged:

Called when left mouse button is dragged for a node accepting user interaction.

- (void)mouseDragged:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

mouseUp:

Called when left mouse button is released for a node accepting user interaction.

- (void)mouseUp:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

otherMouseDown:

Called when middle mouse button is pressed inside a node accepting user interaction.

- (void)otherMouseDown:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

otherMouseDragged:

Called when middle mouse button is dragged for a node accepting user interaction.

- (void)otherMouseDragged:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

otherMouseUp:

Called when middle mouse button is released for a node accepting user interaction.

- (void)otherMouseUp:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

rightMouseDown:

Called when right mouse button is pressed inside a node accepting user interaction.

- (void)rightMouseDown:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

rightMouseDragged:

Called when right mouse button is dragged for a node accepting user interaction.

- (void)rightMouseDragged:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

rightMouseUp:

Called when right mouse button is released for a node accepting user interaction.

- (void)rightMouseUp:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

scrollWheel:

Called when scroll wheel is activated inside a node accepting user interaction.

- (void)scrollWheel:(NSEvent *)theEvent

Parameters

theEvent

The event created.

Declared In

CCResponder.h

touchBegan:withEvent:

Called when a touch began.

- (void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event

Parameters

touch

Contains the touch.

event

Current event information.

Discussion

If a touch is dragged inside a node which does not claim user interaction, a touchBegan will be generated. If node has exclusive touch, all other ongoing touches will be canceled.

If a node wants to grab the touch, touchBegan must be overridden, even if empty. Overriding touchMoved is not enough.

To pass the touch further down the responder chain, call super touchBegan.

if (!thisNodeGrabsTouch) [super touchBegan:touch withEvent:event];

Declared In

CCResponder.h

touchCancelled:withEvent:

Called when a touch was cancelled. If a touch is dragged outside a node which does not claim user interaction, touchCancelled will be called. If another node with exclusive touch is activated, touchCancelled will be called for all ongoing touches.

- (void)touchCancelled:(UITouch *)touch withEvent:(UIEvent *)event

Parameters

touch

Contains the touch.

event

Current event information.

Declared In

CCResponder.h

touchEnded:withEvent:

Called when a touch ends.

- (void)touchEnded:(UITouch *)touch withEvent:(UIEvent *)event

Parameters

touch

Contains the touch.

event

Current event information.

Declared In

CCResponder.h

touchMoved:withEvent:

Called whan a touch moves.

- (void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event

Parameters

touch

Contains the touch.

event

Current event information.

Declared In

CCResponder.h