Declared in CC3CC2Extensions.h

Overview

Extension category to support Cocos3D functionality.

Properties

anchorPointInPoints

The anchorPoint in absolute points.

@property (nonatomic, readonly) CGPoint anchorPointInPoints

Declared In

CC3CC2Extensions.h

boundingBoxInPixels

Cocos2D 2.x compatibility with pixel-based sizing.

@property (nonatomic, readonly) CGRect boundingBoxInPixels

Declared In

CC3CC2Extensions.h

contentSizeInPixels

Cocos2D 2.x compatibility with pixel-based sizing.

@property (nonatomic, readonly) CGSize contentSizeInPixels

Declared In

CC3CC2Extensions.h

globalBoundingBoxInPixels

Returns the bounding box of this CCNode, measured in pixels, in the global coordinate system.

@property (nonatomic, readonly) CGRect globalBoundingBoxInPixels

Declared In

CC3CC2Extensions.h

ignoreAnchorPointForPosition

Use (0,0) when you position the CCNode. Does nothing. Provided for backwards compatibility.

@property (nonatomic, readwrite, assign) BOOL ignoreAnchorPointForPosition

Declared In

CC3CC2Extensions.h

isRunningInActiveScene

Returns YES if the node is added to an active scene and neither it nor any of it’s ancestors is paused.

@property (nonatomic, readonly) BOOL isRunningInActiveScene

Declared In

CC3CC2Extensions.h

mouseEnabled

Returns whether this node will receive mouse events.

@property (nonatomic, readwrite, getter=isMouseEnabled) BOOL mouseEnabled

Discussion

This implementation returns NO.

Declared In

CC3CC2Extensions.h

mousePriority

Dummy property for compatibility with prior Cocos2D versions. Does nothing

@property (nonatomic, assign) NSInteger mousePriority

Declared In

CC3CC2Extensions.h

paused

If paused, no callbacks will be called, and no actions will be run. For compatibility with Cocos2D v3. Setting this property does nothing.

@property (nonatomic, assign) BOOL paused

Declared In

CC3CC2Extensions.h

touchEnabled

Returns whether this node will receive touch events.

@property (nonatomic, readwrite, getter=isTouchEnabled) BOOL touchEnabled

Discussion

This implementation returns NO.

Declared In

CC3CC2Extensions.h

userInteractionEnabled

Enables user interaction (either touch or mouse) on a node.

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

Declared In

CC3CC2Extensions.h

Instance Methods

asCCScene

Convenience method that wraps this node in a CCScene instance, and returns the CCScene instance.

- (CCScene *)asCCScene

Discussion

This node will be held as a child node of the returned CCScene instance.

Declared In

CC3CC2Extensions.h

cc3ContainsTouchPoint:

Returns whether this node contains the specified UI touch location.

- (BOOL)cc3ContainsTouchPoint:(CGPoint)viewPoint

Declared In

CC3CC2Extensions.h

cc3ConvertNSEventToNodeSpace:

Converts an NSEvent (typically a mouse event) to the local coordinates of this node.

- (CGPoint)cc3ConvertNSEventToNodeSpace:(NSEvent *)event

Declared In

CC3CC2Extensions.h

cc3ConvertNodePointToUISpace:

Returns a point in the coordinate space of the UIView that corresponds to the specified point in the coordinate space of this node, taking into consideration the orientation of the device.

- (CGPoint)cc3ConvertNodePointToUISpace:(CGPoint)glPoint

Discussion

This method performs the inverse of the operation provided by the cc3ConvertUIPointToNodeSpace: method.

Declared In

CC3CC2Extensions.h

cc3ConvertUIMovementToNodeSpace:

Returns a movement in the coordinate space of this layer that corresponds to the specified movement in the coordinate space of the UIView, taking into consideration the orientation of the device.

- (CGPoint)cc3ConvertUIMovementToNodeSpace:(CGPoint)uiMovement

Discussion

You can use this method to convert movements in a UIView, including those returned by touch events and gestures, such as the translationInView: and velocityInView: methods of UIPanGestureRecognizer, to movement in this layer.

Declared In

CC3CC2Extensions.h

cc3ConvertUIPointToNodeSpace:

Returns a point in the coordinate space of this node that corresponds to the specified point in the coordinate space of the UIView, taking into consideration the orientation of the device.

- (CGPoint)cc3ConvertUIPointToNodeSpace:(CGPoint)viewPoint

Discussion

You can use this method to convert locations in a UIView, including those returned by touch events and gestures, such as the locationInView: method on tap and long-press gestures, to a location in this layer.

Declared In

CC3CC2Extensions.h

cc3NormalizeUIMovement:

Normalizes the specified movement, which is in the coordinate space of the UIView, so that the movement is made relative to the size of this node.

- (CGPoint)cc3NormalizeUIMovement:(CGPoint)uiMovement

Discussion

The returned value is a fraction proportional to the size of this node. A drag movement from one side of the node all the way to the other side would return positive or negative one in the X or Y component of the returned point. Similarly, a drag movement from the center to one side would return 0.5 in the X or Y component of the returned point.

This method allows you to convert drag movements to a measurement that is independent of the absolute size of the node, and is of a scale useful for processing as input that is not used as a direct positioning value.

You can use this method to normalize movements in a UIView, including those returned by touch events and gestures, such as the translationInView: and velocityInView: methods of UIPanGestureRecognizer, so that they are proportional, and independent of, the size of this node.

This method takes into consideration the orientation of the device.

Declared In

CC3CC2Extensions.h

cc3ValidateGesture:

Validates that the specified gesture is okay to proceed, and cancels the gesture if not. Returns YES if the gesture is valid and okay to proceed. Returns NO if the gesture was cancelled.

- (BOOL)cc3ValidateGesture:(UIGestureRecognizer *)gesture

Discussion

Your gesture handling callback methods should use this method before processing the gesture to ensure that there are no conflicts between the touch events of the gesture and the touch events handled by this node or any of its descendants.

For discrete gestures, such as tap gestures, you should use this method each time the callback is invoked. For many discrete gestures, the callback is only invoked when the gesture is in state UIGestureRecognizerStateEnded.

For continuous gestures, such as pan or pinch gestures, you should use this method when the callback is invoked and the gesture is in state UIGestureRecognizerStateBegan. You do not need to revalidate the continuous gesture on each subsequent callback, when the state of the gesture is UIGestureRecognizerStateChanged. Doing so is unnecessary.

This implementation extracts the location of the touch point from the gesture and uses the cc3WillConsumeTouchEventAt: method of this node to test if this node or any of its descendants are interested in the touch event that triggerd the gesture.

If neither this node nor any descendant is interested in the touch event, this method returns YES. If this node or a descendant is interested in the touch event, the gesture is cancelled and this method returns NO.

Declared In

CC3CC2Extensions.h

cc3WillConsumeTouchEventAt:

Returns whether this node, or any of its descendants will consume a touch event at the specified UIView location when presented with the event.

- (BOOL)cc3WillConsumeTouchEventAt:(CGPoint)viewPoint

Discussion

This method is useful for testing whether a touch event should be handled by a descendant node instead of a gesture recognizer. The result of this method can be used to cancel the gesture recognizer.

Based on Cocos2D Gesture Recognizer ideas by Krzysztof Zabłocki at: http://www.merowing.info/2012/03/using-gesturerecognizers-in-cocos2d/

Declared In

CC3CC2Extensions.h

scheduleUpdate

For backwards compatibility with prior Cocos2D versions. Does nothing.

- (void)scheduleUpdate

Declared In

CC3CC2Extensions.h

updateViewport

Updates the viewport of any contained CC3Scene instances with the dimensions of its CC3Layer and the device orientation.

- (void)updateViewport

Discussion

This CCNode implementation simply passes the notification along to its children. Descendants that are CC3Layers will update their CC3Scene instances.

Declared In

CC3CC2Extensions.h

viewDidResizeTo:

Invoked automatically when the OS view has been resized.

- (void)viewDidResizeTo:(CGSize)newViewSize

Discussion

This implementation simply propagates the same method to the children. Subclasses may override to actually do something when the view resizes.

Declared In

CC3CC2Extensions.h

visit:parentTransform:

Backwards compatibility with Cocos2D 3.x renderer. Simply invoks visit.

- (void)visit:(CCRenderer *)renderer parentTransform:(const GLKMatrix4 *)parentTransform

Declared In

CC3CC2Extensions.h