Inherits from NSObject
Declared in CCNode.h

Overview

CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode. The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu.

The main features of a CCNode are: – They can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc) – They can schedule periodic callback (schedule, unschedule, etc) – They can execute actions (runAction, stopAction, etc)

Some CCNode nodes provide extra functionality for them or their children.

Subclassing a CCNode usually means (one/all) of: – overriding init to initialize resources and schedule callbacks – create callbacks to handle the advancement of time – overriding draw to render the node

Features of CCNode: – position – scale (x, y) – rotation (in degrees, clockwise) – CCCamera (an interface to gluLookAt ) – CCGridBase (to do mesh transformations) – anchor point – size – visible – z-order – openGL z position

Default values: – rotation: 0 – position: (x=0,y=0) – scale: (x=1,y=1) – contentSize: (x=0,y=0) – anchorPoint: (x=0,y=0)

Limitations: – A CCNode is a “void” object. It doesn’t have a texture

Order in transformations with grid disabled –# The node will be translated (position) –# The node will be rotated (rotation) –# The node will be skewed (skewX, skewY) –# The node will be scaled (scale, scaleX, scaleY) –# The node will be moved according to the camera values (camera)

Order in transformations with grid enabled –# The node will be translated (position) –# The node will be rotated (rotation, rotationX, rotationY) –# The node will be skewed (skewX, skewY) –# The node will be scaled (scale, scaleX, scaleY) –# The grid will capture the screen –# The node will be moved according to the camera values (camera) –# The grid will render the captured screen

Camera: – Each node has a camera. By default it points to the center of the CCNode.

Debugging extensions of CCNode. They are available when the DEBUG macro is defined at compile time

extends CCNode

Tasks

Other Methods

  •   zOrder

    The z order of the node relative to its “siblings”: children of the same parent

    property
  •   vertexZ

    The real openGL Z vertex. Differences between openGL Z vertex and cocos2d Z order: – OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children – OpenGL Z might require to set 2D projection – cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0 @warning: Use it at your own risk since it might break the cocos2d parent-children z order

    property
  •   skewX

    The X skew angle of the node in degrees. This angle describes the shear distortion in the X direction. Thus, it is the angle between the Y axis and the left edge of the shape The default skewX angle is 0. Positive values distort the node in a CW direction.

    property
  •   skewY

    The Y skew angle of the node in degrees. This angle describes the shear distortion in the Y direction. Thus, it is the angle between the X axis and the bottom edge of the shape The default skewY angle is 0. Positive values distort the node in a CCW direction.

    property
  •   rotation

    The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW.

    property
  •   rotationX

    The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the X rotation performing a horizontal rotational skew .

    property
  •   rotationY

    The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the Y rotation performing a vertical rotational skew .

    property
  •   scale

    The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time.

    property
  •   scaleX

    The scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor.

    property
  •   scaleY

    The scale factor of the node. 1.0 is the default scale factor. It only modifies the Y scale factor.

    property
  •   position

    Position (x,y) of the node in points. (0,0) is the left-bottom corner.

    property
  •   camera

    A CCCamera object that lets you move the node using a gluLookAt

    property
  •   children

    Array of children

    property
  •   grid

    A CCGrid object that is used when applying effects

    property
  •   visible

    Whether of not the node is visible. Default is YES

    property
  •   anchorPoint

    anchorPoint is the point around which all transformations and positioning manipulations take place. It’s like a pin in the node where it is “attached” to its parent. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. But you can use values higher than (1,1) and lower than (0,0) too. The default anchorPoint is (0,0). It starts in the bottom-left corner. CCSprite and other subclasses have a different default anchorPoint.

    property
  •   anchorPointInPoints

    The anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead

    property
  •   contentSize

    The untransformed size of the node in Points The contentSize remains the same no matter the node is scaled or rotated. All nodes has a size. Layer and Scene has the same size of the screen.

    property
  •   isRunning

    whether or not the node is running

    property
  •   parent

    A weak reference to the parent

    property
  •   ignoreAnchorPointForPosition

    If YES, the Anchor Point will be (0,0) when you position the CCNode. Used by CCLayer and CCScene.

    property
  •   tag

    A tag used to identify the node easily

    property
  •   userData

    A custom user data pointer

    property
  •   userObject

    Similar to userData, but instead of holding a void* it holds an id

    property
  •   shaderProgram

    Shader Program

    property
  •   orderOfArrival

    used internally for zOrder sorting, don’t change this manually

    property
  •   glServerState

    GL server side state

    property
  •   actionManager

    CCActionManager used by all the actions. IMPORTANT: If you set a new CCActionManager, then previously created actions are going to be removed.

    property
  •   scheduler

    CCScheduler used to schedule all “updates” and timers. IMPORTANT: If you set a new CCScheduler, then previously created timers/update are going to be removed.

    property
  • + node

    allocates and initializes a node. The node will be created as “autorelease”.

  • – init

    initializes the node

  • – onEnter

    Event that is called every time the CCNode enters the ‘stage’. If the CCNode enters the ‘stage’ with a transition, this event is called when the transition starts. During onEnter you can’t access a sibling node. If you override onEnter, you shall call [super onEnter].

  • – onEnterTransitionDidFinish

    Event that is called when the CCNode enters in the ‘stage’. If the CCNode enters the ‘stage’ with a transition, this event is called when the transition finishes. If you override onEnterTransitionDidFinish, you shall call [super onEnterTransitionDidFinish].

  • – onExit

    Event that is called every time the CCNode leaves the ‘stage’. If the CCNode leaves the ‘stage’ with a transition, this event is called when the transition finishes. During onExit you can’t access a sibling node. If you override onExit, you shall call [super onExit].

  • – onExitTransitionDidStart

    callback that is called every time the CCNode leaves the ‘stage’. If the CCNode leaves the ‘stage’ with a transition, this callback is called when the transition starts.

  • – addChild:

    Adds a child to the container with z-order as 0. If the child is added to a ‘running’ node, then ‘onEnter’ and ‘onEnterTransitionDidFinish’ will be called immediately.

  • – addChild:z:

    Adds a child to the container with a z-order. If the child is added to a ‘running’ node, then ‘onEnter’ and ‘onEnterTransitionDidFinish’ will be called immediately.

  • – addChild:z:tag:

    Adds a child to the container with z order and tag. If the child is added to a ‘running’ node, then ‘onEnter’ and ‘onEnterTransitionDidFinish’ will be called immediately.

  • – removeFromParent

    Remove itself from its parent node forcing a cleanup. If the node orphan, then nothing happens.

  • – removeFromParentAndCleanup:

    Remove itself from its parent node. If cleanup is YES, then also remove all actions and callbacks. If the node orphan, then nothing happens.

  • – removeChild:

    Removes a child from the container forcing a cleanup

  • – removeChild:cleanup:

    Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

  • – removeChildByTag:

    Removes a child from the container by tag value forcing a cleanup.

  • – removeChildByTag:cleanup:

    Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter

  • – removeAllChildren

    Removes all children from the container forcing a cleanup.

  • – removeAllChildrenWithCleanup:

    Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.

  • – getChildByTag:

    Gets a child from the container given its tag

  • – reorderChild:z:

    Reorders a child according to a new z value. The child MUST be already added.

  • – sortAllChildren

    performance improvement, Sort the children array once before drawing, instead of every time when a child is added or reordered don’t call this manually unless a child added needs to be removed in the same frame

  • – cleanup

    Event that is called when the running node is no longer running (eg: its CCScene is being removed from the “stage” ). On cleanup you should break any possible circular references. CCNode’s cleanup removes any possible scheduled timer and/or any possible action. If you override cleanup, you shall call [super cleanup]

  • – draw

    Override this method to draw your own node. You should use cocos2d’s GL API to enable/disable the GL state / shaders. For further info, please see ccGLstate.h. You shall NOT call [super draw];

  • – visit

    recursive method that visit its children and draw them

  • – transform

    performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.

  • – transformAncestors

    performs OpenGL view-matrix transformation of its ancestors. Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) it is necessary to transform the ancestors again.

  • – boundingBox

    returns a “local” axis aligned bounding box of the node in points. The returned box is relative only to its parent. The returned box is in Points.

  • – runAction:

    Executes an action, and returns the action that is executed. The node becomes the action’s target.

  • – stopAllActions

    Removes all actions from the running action list

  • – stopAction:

    Removes an action from the running action list

  • – stopActionByTag:

    Removes an action from the running action list given its tag

  • – getActionByTag:

    Gets an action from the running action list given its tag

  • – numberOfRunningActions

    Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays). Composable actions are counted as 1 action. Example: If you are running 1 Sequence of 7 actions, it will return 1. If you are running 7 Sequences of 2 actions, it will return 7.

  • – scheduleUpdate

    schedules the “update” method. It will use the order number 0. This method will be called every frame. Scheduled methods with a lower order value will be called before the ones that have a higher order value. Only one “update” method could be scheduled per node.

  • – scheduleUpdateWithPriority:

    schedules the “update” selector with a custom priority. This selector will be called every frame. Scheduled selectors with a lower priority will be called before the ones that have a higher value. Only one “update” selector could be scheduled per node (You can’t have 2 ‘update’ selectors).

  • – unscheduleUpdate
  • – schedule:

    schedules a selector. The scheduled selector will be ticked every frame

  • – schedule:interval:

    schedules a custom selector with an interval time in seconds. If time is 0 it will be ticked every frame. If time is 0, it is recommended to use ‘scheduleUpdate’ instead.

  • – schedule:interval:repeat:delay:

    repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever delay is the amount of time the action will wait before execution

  • – scheduleOnce:delay:

    Schedules a selector that runs only once, with a delay of 0 or larger

  • – unschedule:

    unschedules a custom selector.

  • – unscheduleAllSelectors

    unschedule all scheduled selectors: custom selectors, and the ‘update’ selector. Actions are not affected by this method.

  • – resumeSchedulerAndActions

    resumes all scheduled selectors and actions. Called internally by onEnter

  • – pauseSchedulerAndActions

    pauses all scheduled selectors and actions. Called internally by onExit

  • – update:
  • – nodeToParentTransform

    Returns the matrix that transform the node’s (local) space coordinates into the parent’s space coordinates. The matrix is in Pixels.

  • – parentToNodeTransform

    Returns the matrix that transform parent’s space coordinates to the node’s (local) space coordinates. The matrix is in Pixels.

  • – nodeToWorldTransform

    Returns the world affine transform matrix. The matrix is in Pixels.

  • – worldToNodeTransform

    Returns the inverse world affine transform matrix. The matrix is in Pixels.

  • – convertToNodeSpace:

    Converts a Point to node (local) space coordinates. The result is in Points.

  • – convertToWorldSpace:

    Converts a Point to world space coordinates. The result is in Points.

  • – convertToNodeSpaceAR:

    Converts a Point to node (local) space coordinates. The result is in Points. treating the returned/received node point as anchor relative.

  • – convertToWorldSpaceAR:

    Converts a local Point to world space coordinates.The result is in Points. treating the returned/received node point as anchor relative.

  • – convertTouchToNodeSpace:

    Converts a UITouch to node (local) space coordinates. The result is in Points.

  • – convertTouchToNodeSpaceAR:

    Converts a UITouch to node (local) space coordinates. The result is in Points. This method is AR (Anchor Relative)..

Other Methods

  •   anchorPointInPixels

    The anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead

    property
  •   isRelativeAnchorPoint

    If YES the transformtions will be relative to it’s anchor point. Sprites, Labels and any other sizeble object use it have it enabled by default. Scenes, Layers and other “whole screen” object don’t use it, have it disabled by default.

    property

Deprecated Methods

Debug Methods

extension Methods

KoboldExtensions Methods

  • – containsPoint:

    Returns true if the point is contained in (is on) the node. Respects rotation and scaling of the node.

  • – containsTouch:

    Returns true if the UITouch is contained in (is on) the node. Respects rotation and scaling of the node.

  • – intersectsNode:

    Returns true if the node’s boundingBox intersects with the boundingBox of another node.

  • + nodeWithScene

    Calls the node’s “node” method to initialize it, then adds it to a CCScene object and returns that CCScene. Useful as a convenience method for creating a CCLayer instance wrapped in a scene, so that you can write:

  • – transferToNode:

    This transfers the node (self) from its current parent node to a different node (new parent). This can be used to transfer a node from one scene to a new scene, for example. The node must already have a parent (ie it must have been added with addChild).

  • – removeChildrenInArray:cleanup:

    remove all childs in the given CCArray or NSMutableArray (or any other collection supporting NSFastEnumeration)

  • – setPositionRelativeToParentPosition:

    Sets position relative to parent’s position, disregarding cocos2d’s usual behavior where the origin of child nodes is at the lower left corner of their parent’s contentSize (relative to anchor point). This method just does what you would expect: that the child position is relative to the parent’s position irregardless of the parent’s contentSize or anchorPoint properties.

  •   boundingBoxCenter

    Returns the center position of the node’s bounding box.

    property
  •   size

    Changes the size of the node (if supported, for example CCLayerColor).

    property

ContentSize Methods

Properties

actionManager

CCActionManager used by all the actions. IMPORTANT: If you set a new CCActionManager, then previously created actions are going to be removed.

@property (nonatomic, readwrite, retain) CCActionManager *actionManager

Availability

Declared In

CCNode.h

anchorPoint

anchorPoint is the point around which all transformations and positioning manipulations take place. It’s like a pin in the node where it is “attached” to its parent. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. But you can use values higher than (1,1) and lower than (0,0) too. The default anchorPoint is (0,0). It starts in the bottom-left corner. CCSprite and other subclasses have a different default anchorPoint.

@property (nonatomic, readwrite) CGPoint anchorPoint

Availability

Declared In

CCNode.h

anchorPointInPixels

The anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead

@property (nonatomic, readonly) CGPoint anchorPointInPixels

Declared In

CCNode.h

anchorPointInPoints

The anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead

@property (nonatomic, readonly) CGPoint anchorPointInPoints

Declared In

CCNode.h

boundingBoxCenter

Returns the center position of the node’s bounding box.

@property (nonatomic, readonly) CGPoint boundingBoxCenter

Declared In

CCNodeExtensions.h

camera

A CCCamera object that lets you move the node using a gluLookAt

@property (nonatomic, readonly) CCCamera *camera

Declared In

CCNode.h

children

Array of children

@property (nonatomic, readonly) CCArray *children

Declared In

CCNode.h

contentSize

The untransformed size of the node in Points The contentSize remains the same no matter the node is scaled or rotated. All nodes has a size. Layer and Scene has the same size of the screen.

@property (nonatomic, readwrite) CGSize contentSize

Availability

Declared In

CCNode.h

glServerState

GL server side state

@property (nonatomic, readwrite) ccGLServerState glServerState

Availability

Declared In

CCNode.h

grid

A CCGrid object that is used when applying effects

@property (nonatomic, readwrite, retain) CCGridBase *grid

Declared In

CCNode.h

ignoreAnchorPointForPosition

If YES, the Anchor Point will be (0,0) when you position the CCNode. Used by CCLayer and CCScene.

@property (nonatomic, readwrite, assign) BOOL ignoreAnchorPointForPosition

Declared In

CCNode.h

isRelativeAnchorPoint

If YES the transformtions will be relative to it’s anchor point. Sprites, Labels and any other sizeble object use it have it enabled by default. Scenes, Layers and other “whole screen” object don’t use it, have it disabled by default.

@property (nonatomic, readwrite, assign) BOOL isRelativeAnchorPoint

Declared In

CCNode.h

isRunning

whether or not the node is running

@property (nonatomic, readonly) BOOL isRunning

Declared In

CCNode.h

orderOfArrival

used internally for zOrder sorting, don’t change this manually

@property (nonatomic, readwrite) NSUInteger orderOfArrival

Declared In

CCNode.h

parent

A weak reference to the parent

@property (nonatomic, readwrite, assign) CCNode *parent

Declared In

CCNode.h

position

Position (x,y) of the node in points. (0,0) is the left-bottom corner.

@property (nonatomic, readwrite, assign) CGPoint position

Declared In

CCNode.h

rotation

The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW.

@property (nonatomic, readwrite, assign) float rotation

Declared In

CCNode.h

rotationX

The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the X rotation performing a horizontal rotational skew .

@property (nonatomic, readwrite, assign) float rotationX

Declared In

CCNode.h

rotationY

The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the Y rotation performing a vertical rotational skew .

@property (nonatomic, readwrite, assign) float rotationY

Declared In

CCNode.h

scale

The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time.

@property (nonatomic, readwrite, assign) float scale

Declared In

CCNode.h

scaleX

The scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor.

@property (nonatomic, readwrite, assign) float scaleX

Declared In

CCNode.h

scaleY

The scale factor of the node. 1.0 is the default scale factor. It only modifies the Y scale factor.

@property (nonatomic, readwrite, assign) float scaleY

Declared In

CCNode.h

scheduler

CCScheduler used to schedule all “updates” and timers. IMPORTANT: If you set a new CCScheduler, then previously created timers/update are going to be removed.

@property (nonatomic, readwrite, retain) CCScheduler *scheduler

Availability

Declared In

CCNode.h

shaderProgram

Shader Program

@property (nonatomic, readwrite, retain) CCGLProgram *shaderProgram

Availability

Declared In

CCNode.h

size

Changes the size of the node (if supported, for example CCLayerColor).

@property (nonatomic) CGSize size

Declared In

CCNodeExtensions.h

skewX

The X skew angle of the node in degrees. This angle describes the shear distortion in the X direction. Thus, it is the angle between the Y axis and the left edge of the shape The default skewX angle is 0. Positive values distort the node in a CW direction.

@property (nonatomic, readwrite, assign) float skewX

Declared In

CCNode.h

skewY

The Y skew angle of the node in degrees. This angle describes the shear distortion in the Y direction. Thus, it is the angle between the X axis and the bottom edge of the shape The default skewY angle is 0. Positive values distort the node in a CCW direction.

@property (nonatomic, readwrite, assign) float skewY

Declared In

CCNode.h

tag

A tag used to identify the node easily

@property (nonatomic, readwrite, assign) NSInteger tag

Declared In

CCNode.h

userData

A custom user data pointer

@property (nonatomic, readwrite, assign) void *userData

Declared In

CCNode.h

userObject

Similar to userData, but instead of holding a void* it holds an id

@property (nonatomic, readwrite, retain) id userObject

Declared In

CCNode.h

vertexZ

The real openGL Z vertex. Differences between openGL Z vertex and cocos2d Z order: – OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children – OpenGL Z might require to set 2D projection – cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0 @warning: Use it at your own risk since it might break the cocos2d parent-children z order

@property (nonatomic, readwrite) float vertexZ

Availability

Declared In

CCNode.h

visible

Whether of not the node is visible. Default is YES

@property (nonatomic, readwrite, assign) BOOL visible

Declared In

CCNode.h

zOrder

The z order of the node relative to its “siblings”: children of the same parent

@property (nonatomic, assign) NSInteger zOrder

Declared In

CCNode.h

Class Methods

node

allocates and initializes a node. The node will be created as “autorelease”.

+ (id)node

Declared In

CCNode.h

nodeWithScene

Calls the node’s “node” method to initialize it, then adds it to a CCScene object and returns that CCScene. Useful as a convenience method for creating a CCLayer instance wrapped in a scene, so that you can write:

+ (id)nodeWithScene

Discussion

[[CCDirector sharedDirector] replaceScene:[MyGameLayer nodeWithScene]];

Declared In

CCNodeExtensions.h

Instance Methods

addChild:

Adds a child to the container with z-order as 0. If the child is added to a ‘running’ node, then ‘onEnter’ and ‘onEnterTransitionDidFinish’ will be called immediately.

- (void)addChild:(CCNode *)node

Availability

Declared In

CCNode.h

addChild:z:

Adds a child to the container with a z-order. If the child is added to a ‘running’ node, then ‘onEnter’ and ‘onEnterTransitionDidFinish’ will be called immediately.

- (void)addChild:(CCNode *)node z:(NSInteger)z

Availability

Declared In

CCNode.h

addChild:z:tag:

Adds a child to the container with z order and tag. If the child is added to a ‘running’ node, then ‘onEnter’ and ‘onEnterTransitionDidFinish’ will be called immediately.

- (void)addChild:(CCNode *)node z:(NSInteger)z tag:(NSInteger)tag

Availability

Declared In

CCNode.h

boundingBox

returns a “local” axis aligned bounding box of the node in points. The returned box is relative only to its parent. The returned box is in Points.

- (CGRect)boundingBox

Availability

Declared In

CCNode.h

cleanup

Event that is called when the running node is no longer running (eg: its CCScene is being removed from the “stage” ). On cleanup you should break any possible circular references. CCNode’s cleanup removes any possible scheduled timer and/or any possible action. If you override cleanup, you shall call [super cleanup]

- (void)cleanup

Availability

Declared In

CCNode.h

containsPoint:

Returns true if the point is contained in (is on) the node. Respects rotation and scaling of the node.

- (BOOL)containsPoint:(CGPoint)point

Declared In

CCNodeExtensions.h

containsTouch:

Returns true if the UITouch is contained in (is on) the node. Respects rotation and scaling of the node.

- (BOOL)containsTouch:(UITouch *)touch

Declared In

CCNodeExtensions.h

convertToNodeSpace:

Converts a Point to node (local) space coordinates. The result is in Points.

- (CGPoint)convertToNodeSpace:(CGPoint)worldPoint

Availability

Declared In

CCNode.h

convertToNodeSpaceAR:

Converts a Point to node (local) space coordinates. The result is in Points. treating the returned/received node point as anchor relative.

- (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint

Availability

Declared In

CCNode.h

convertToWorldSpace:

Converts a Point to world space coordinates. The result is in Points.

- (CGPoint)convertToWorldSpace:(CGPoint)nodePoint

Availability

Declared In

CCNode.h

convertToWorldSpaceAR:

Converts a local Point to world space coordinates.The result is in Points. treating the returned/received node point as anchor relative.

- (CGPoint)convertToWorldSpaceAR:(CGPoint)nodePoint

Availability

Declared In

CCNode.h

convertTouchToNodeSpace:

Converts a UITouch to node (local) space coordinates. The result is in Points.

- (CGPoint)convertTouchToNodeSpace:(UITouch *)touch

Availability

Declared In

CCNode.h

convertTouchToNodeSpaceAR:

Converts a UITouch to node (local) space coordinates. The result is in Points. This method is AR (Anchor Relative)..

- (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touch

Availability

Declared In

CCNode.h

draw

Override this method to draw your own node. You should use cocos2d’s GL API to enable/disable the GL state / shaders. For further info, please see ccGLstate.h. You shall NOT call [super draw];

- (void)draw

Declared In

CCNode.h

getActionByTag:

Gets an action from the running action list given its tag

- (CCAction *)getActionByTag:(NSInteger)tag

Return Value

the Action the with the given tag

Availability

Declared In

CCNode.h

getChildByTag:

Gets a child from the container given its tag

- (CCNode *)getChildByTag:(NSInteger)tag

Return Value

returns a CCNode object

Availability

Declared In

CCNode.h

init

initializes the node

- (id)init

Declared In

CCNode.h

intersectsNode:

Returns true if the node’s boundingBox intersects with the boundingBox of another node.

- (BOOL)intersectsNode:(CCNode *)other

Declared In

CCNodeExtensions.h

isRelativeAnchorPoint

minimalDimensionsForChildren

nodeToParentTransform

Returns the matrix that transform the node’s (local) space coordinates into the parent’s space coordinates. The matrix is in Pixels.

- (CGAffineTransform)nodeToParentTransform

Availability

Declared In

CCNode.h

nodeToWorldTransform

Returns the world affine transform matrix. The matrix is in Pixels.

- (CGAffineTransform)nodeToWorldTransform

Availability

Declared In

CCNode.h

numberOfRunningActions

Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays). Composable actions are counted as 1 action. Example: If you are running 1 Sequence of 7 actions, it will return 1. If you are running 7 Sequences of 2 actions, it will return 7.

- (NSUInteger)numberOfRunningActions

Declared In

CCNode.h

onEnter

Event that is called every time the CCNode enters the ‘stage’. If the CCNode enters the ‘stage’ with a transition, this event is called when the transition starts. During onEnter you can’t access a sibling node. If you override onEnter, you shall call [super onEnter].

- (void)onEnter

Declared In

CCNode.h

onEnterTransitionDidFinish

Event that is called when the CCNode enters in the ‘stage’. If the CCNode enters the ‘stage’ with a transition, this event is called when the transition finishes. If you override onEnterTransitionDidFinish, you shall call [super onEnterTransitionDidFinish].

- (void)onEnterTransitionDidFinish

Availability

Declared In

CCNode.h

onExit

Event that is called every time the CCNode leaves the ‘stage’. If the CCNode leaves the ‘stage’ with a transition, this event is called when the transition finishes. During onExit you can’t access a sibling node. If you override onExit, you shall call [super onExit].

- (void)onExit

Declared In

CCNode.h

onExitTransitionDidStart

callback that is called every time the CCNode leaves the ‘stage’. If the CCNode leaves the ‘stage’ with a transition, this callback is called when the transition starts.

- (void)onExitTransitionDidStart

Declared In

CCNode.h

parentToNodeTransform

Returns the matrix that transform parent’s space coordinates to the node’s (local) space coordinates. The matrix is in Pixels.

- (CGAffineTransform)parentToNodeTransform

Availability

Declared In

CCNode.h

pauseSchedulerAndActions

pauses all scheduled selectors and actions. Called internally by onExit

- (void)pauseSchedulerAndActions

Declared In

CCNode.h

removeAllChildren

Removes all children from the container forcing a cleanup.

- (void)removeAllChildren

Availability

Declared In

CCNode.h

removeAllChildrenWithCleanup:

Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.

- (void)removeAllChildrenWithCleanup:(BOOL)cleanup

Availability

Declared In

CCNode.h

removeChild:

Removes a child from the container forcing a cleanup

- (void)removeChild:(CCNode *)child

Availability

Declared In

CCNode.h

removeChild:cleanup:

Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.

- (void)removeChild:(CCNode *)node cleanup:(BOOL)cleanup

Availability

Declared In

CCNode.h

removeChildByTag:

Removes a child from the container by tag value forcing a cleanup.

- (void)removeChildByTag:(NSInteger)tag

Availability

Declared In

CCNode.h

removeChildByTag:cleanup:

Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter

- (void)removeChildByTag:(NSInteger)tag cleanup:(BOOL)cleanup

Availability

Declared In

CCNode.h

removeChildrenInArray:cleanup:

remove all childs in the given CCArray or NSMutableArray (or any other collection supporting NSFastEnumeration)

- (void)removeChildrenInArray:(id<NSFastEnumeration>)childArray cleanup:(BOOL)cleanup

Declared In

CCNodeExtensions.h

removeFromParent

Remove itself from its parent node forcing a cleanup. If the node orphan, then nothing happens.

- (void)removeFromParent

Availability

Declared In

CCNode.h

removeFromParentAndCleanup:

Remove itself from its parent node. If cleanup is YES, then also remove all actions and callbacks. If the node orphan, then nothing happens.

- (void)removeFromParentAndCleanup:(BOOL)cleanup

Availability

Declared In

CCNode.h

reorderChild:z:

Reorders a child according to a new z value. The child MUST be already added.

- (void)reorderChild:(CCNode *)child z:(NSInteger)zOrder

Declared In

CCNode.h

resumeSchedulerAndActions

resumes all scheduled selectors and actions. Called internally by onEnter

- (void)resumeSchedulerAndActions

Declared In

CCNode.h

runAction:

Executes an action, and returns the action that is executed. The node becomes the action’s target.

- (CCAction *)runAction:(CCAction *)action

Return Value

An Action pointer

Availability

Discussion

Warning: Starting from v0.8 actions don’t retain their target anymore.

Declared In

CCNode.h

schedule:

schedules a selector. The scheduled selector will be ticked every frame

- (void)schedule:(SEL)s

Declared In

CCNode.h

schedule:interval:

schedules a custom selector with an interval time in seconds. If time is 0 it will be ticked every frame. If time is 0, it is recommended to use ‘scheduleUpdate’ instead.

- (void)schedule:(SEL)s interval:(ccTime)seconds

Discussion

If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.

Declared In

CCNode.h

schedule:interval:repeat:delay:

repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever delay is the amount of time the action will wait before execution

- (void)schedule:(SEL)selector interval:(ccTime)interval repeat:(uint)repeat delay:(ccTime)delay

Declared In

CCNode.h

scheduleOnce:delay:

Schedules a selector that runs only once, with a delay of 0 or larger

- (void)scheduleOnce:(SEL)selector delay:(ccTime)delay

Declared In

CCNode.h

scheduleUpdate

schedules the “update” method. It will use the order number 0. This method will be called every frame. Scheduled methods with a lower order value will be called before the ones that have a higher order value. Only one “update” method could be scheduled per node.

- (void)scheduleUpdate

Availability

Declared In

CCNode.h

scheduleUpdateWithPriority:

schedules the “update” selector with a custom priority. This selector will be called every frame. Scheduled selectors with a lower priority will be called before the ones that have a higher value. Only one “update” selector could be scheduled per node (You can’t have 2 ‘update’ selectors).

- (void)scheduleUpdateWithPriority:(NSInteger)priority

Availability

Declared In

CCNode.h

setContentSizeFromChildren

setIsRelativeAnchorPoint:

setPositionRelativeToParentPosition:

Sets position relative to parent’s position, disregarding cocos2d’s usual behavior where the origin of child nodes is at the lower left corner of their parent’s contentSize (relative to anchor point). This method just does what you would expect: that the child position is relative to the parent’s position irregardless of the parent’s contentSize or anchorPoint properties.

- (void)setPositionRelativeToParentPosition:(CGPoint)pos

Declared In

CCNodeExtensions.h

setZOrder:

sortAllChildren

performance improvement, Sort the children array once before drawing, instead of every time when a child is added or reordered don’t call this manually unless a child added needs to be removed in the same frame

- (void)sortAllChildren

Declared In

CCNode.h

stopAction:

Removes an action from the running action list

- (void)stopAction:(CCAction *)action

Declared In

CCNode.h

stopActionByTag:

Removes an action from the running action list given its tag

- (void)stopActionByTag:(NSInteger)tag

Availability

Declared In

CCNode.h

stopAllActions

Removes all actions from the running action list

- (void)stopAllActions

Declared In

CCNode.h

transferToNode:

This transfers the node (self) from its current parent node to a different node (new parent). This can be used to transfer a node from one scene to a new scene, for example. The node must already have a parent (ie it must have been added with addChild).

- (void)transferToNode:(CCNode *)targetNode

Declared In

CCNodeExtensions.h

transform

performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.

- (void)transform

Declared In

CCNode.h

transformAncestors

performs OpenGL view-matrix transformation of its ancestors. Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) it is necessary to transform the ancestors again.

- (void)transformAncestors

Availability

Declared In

CCNode.h

unschedule:

unschedules a custom selector.

- (void)unschedule:(SEL)s

Declared In

CCNode.h

unscheduleAllSelectors

unschedule all scheduled selectors: custom selectors, and the ‘update’ selector. Actions are not affected by this method.

- (void)unscheduleAllSelectors

Availability

Declared In

CCNode.h

unscheduleUpdate

update:

visit

recursive method that visit its children and draw them

- (void)visit

Declared In

CCNode.h

walkSceneGraph:

prints on the debug console the scene graph

- (void)walkSceneGraph:(NSUInteger)level

Declared In

CCNode+Debug.h

worldToNodeTransform

Returns the inverse world affine transform matrix. The matrix is in Pixels.

- (CGAffineTransform)worldToNodeTransform

Availability

Declared In

CCNode.h