CCNode Class Reference
| 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
-
zOrderThe z order of the node relative to its “siblings”: children of the same parent
property -
vertexZThe 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 -
skewXThe 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 -
skewYThe 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 -
rotationThe rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW.
property -
rotationXThe 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 -
rotationYThe 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 -
scaleThe scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time.
property -
scaleXThe scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor.
property -
scaleYThe scale factor of the node. 1.0 is the default scale factor. It only modifies the Y scale factor.
property -
positionPosition (x,y) of the node in points. (0,0) is the left-bottom corner.
property -
cameraA CCCamera object that lets you move the node using a gluLookAt
property -
childrenArray of children
property -
gridA CCGrid object that is used when applying effects
property -
visibleWhether of not the node is visible. Default is YES
property -
anchorPointanchorPoint 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 -
anchorPointInPointsThe anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead
property -
contentSizeThe 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 -
isRunningwhether or not the node is running
property -
parentA weak reference to the parent
property -
ignoreAnchorPointForPositionIf YES, the Anchor Point will be (0,0) when you position the CCNode. Used by CCLayer and CCScene.
property -
tagA tag used to identify the node easily
property -
userDataA custom user data pointer
property -
userObjectSimilar to userData, but instead of holding a void* it holds an id
property -
shaderProgramShader Program
property -
orderOfArrivalused internally for zOrder sorting, don’t change this manually
property -
glServerStateGL server side state
property -
actionManagerCCActionManager used by all the actions. IMPORTANT: If you set a new CCActionManager, then previously created actions are going to be removed.
property -
schedulerCCScheduler 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 -
+ nodeallocates and initializes a node. The node will be created as “autorelease”.
-
– initinitializes the node
-
– onEnterEvent 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].
-
– onEnterTransitionDidFinishEvent 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].
-
– onExitEvent 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].
-
– onExitTransitionDidStartcallback 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.
-
– removeFromParentRemove 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
-
– removeAllChildrenRemoves 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.
-
– sortAllChildrenperformance 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
-
– cleanupEvent 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]
-
– drawOverride 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];
-
– visitrecursive method that visit its children and draw them
-
– transformperforms OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
-
– transformAncestorsperforms 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.
-
– boundingBoxreturns 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.
-
– stopAllActionsRemoves 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
-
– numberOfRunningActionsReturns 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.
-
– scheduleUpdateschedules 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.
-
– unscheduleAllSelectorsunschedule all scheduled selectors: custom selectors, and the ‘update’ selector. Actions are not affected by this method.
-
– resumeSchedulerAndActionsresumes all scheduled selectors and actions. Called internally by onEnter
-
– pauseSchedulerAndActionspauses all scheduled selectors and actions. Called internally by onExit
-
– update: -
– nodeToParentTransformReturns the matrix that transform the node’s (local) space coordinates into the parent’s space coordinates. The matrix is in Pixels.
-
– parentToNodeTransformReturns the matrix that transform parent’s space coordinates to the node’s (local) space coordinates. The matrix is in Pixels.
-
– nodeToWorldTransformReturns the world affine transform matrix. The matrix is in Pixels.
-
– worldToNodeTransformReturns 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
-
anchorPointInPixelsThe anchorPoint in absolute pixels. Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead
property -
isRelativeAnchorPointIf 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
-
– walkSceneGraph:prints on the debug console the scene graph
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.
-
+ nodeWithSceneCalls 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.
-
boundingBoxCenterReturns the center position of the node’s bounding box.
property -
sizeChanges 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 *actionManagerAvailability
Declared In
CCNode.hanchorPoint
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 anchorPointAvailability
Declared In
CCNode.hanchorPointInPixels
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 anchorPointInPixelsDeclared In
CCNode.hanchorPointInPoints
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 anchorPointInPointsDeclared In
CCNode.hboundingBoxCenter
Returns the center position of the node’s bounding box.
@property (nonatomic, readonly) CGPoint boundingBoxCenterDeclared In
CCNodeExtensions.hcamera
A CCCamera object that lets you move the node using a gluLookAt
@property (nonatomic, readonly) CCCamera *cameraDeclared In
CCNode.hcontentSize
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 contentSizeAvailability
Declared In
CCNode.hglServerState
GL server side state
@property (nonatomic, readwrite) ccGLServerState glServerStateAvailability
Declared In
CCNode.hgrid
A CCGrid object that is used when applying effects
@property (nonatomic, readwrite, retain) CCGridBase *gridDeclared In
CCNode.hignoreAnchorPointForPosition
If YES, the Anchor Point will be (0,0) when you position the CCNode. Used by CCLayer and CCScene.
@property (nonatomic, readwrite, assign) BOOL ignoreAnchorPointForPositionDeclared In
CCNode.hisRelativeAnchorPoint
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 isRelativeAnchorPointDeclared In
CCNode.hisRunning
whether or not the node is running
@property (nonatomic, readonly) BOOL isRunningDeclared In
CCNode.horderOfArrival
used internally for zOrder sorting, don’t change this manually
@property (nonatomic, readwrite) NSUInteger orderOfArrivalDeclared In
CCNode.hparent
A weak reference to the parent
@property (nonatomic, readwrite, assign) CCNode *parentDeclared In
CCNode.hposition
Position (x,y) of the node in points. (0,0) is the left-bottom corner.
@property (nonatomic, readwrite, assign) CGPoint positionDeclared In
CCNode.hrotation
The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW.
@property (nonatomic, readwrite, assign) float rotationDeclared In
CCNode.hrotationX
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 rotationXDeclared In
CCNode.hrotationY
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 rotationYDeclared In
CCNode.hscale
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 scaleDeclared In
CCNode.hscaleX
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 scaleXDeclared In
CCNode.hscaleY
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 scaleYDeclared In
CCNode.hscheduler
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 *schedulerAvailability
Declared In
CCNode.hshaderProgram
Shader Program
@property (nonatomic, readwrite, retain) CCGLProgram *shaderProgramAvailability
Declared In
CCNode.hsize
Changes the size of the node (if supported, for example CCLayerColor).
@property (nonatomic) CGSize sizeDeclared In
CCNodeExtensions.hskewX
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 skewXDeclared In
CCNode.hskewY
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 skewYDeclared In
CCNode.htag
A tag used to identify the node easily
@property (nonatomic, readwrite, assign) NSInteger tagDeclared In
CCNode.huserData
A custom user data pointer
@property (nonatomic, readwrite, assign) void *userDataDeclared In
CCNode.huserObject
Similar to userData, but instead of holding a void* it holds an id
@property (nonatomic, readwrite, retain) id userObjectDeclared In
CCNode.hvertexZ
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 vertexZAvailability
Declared In
CCNode.hClass Methods
node
allocates and initializes a node. The node will be created as “autorelease”.
+ (id)nodeDeclared In
CCNode.hnodeWithScene
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)nodeWithSceneDiscussion
[[CCDirector sharedDirector] replaceScene:[MyGameLayer nodeWithScene]];
Declared In
CCNodeExtensions.hInstance 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 *)nodeAvailability
Declared In
CCNode.haddChild: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)zAvailability
Declared In
CCNode.haddChild: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)tagAvailability
Declared In
CCNode.hboundingBox
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)boundingBoxAvailability
Declared In
CCNode.hcleanup
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)cleanupAvailability
Declared In
CCNode.hcontainsPoint:
Returns true if the point is contained in (is on) the node. Respects rotation and scaling of the node.
- (BOOL)containsPoint:(CGPoint)pointDeclared In
CCNodeExtensions.hcontainsTouch:
Returns true if the UITouch is contained in (is on) the node. Respects rotation and scaling of the node.
- (BOOL)containsTouch:(UITouch *)touchDeclared In
CCNodeExtensions.hconvertToNodeSpace:
Converts a Point to node (local) space coordinates. The result is in Points.
- (CGPoint)convertToNodeSpace:(CGPoint)worldPointAvailability
Declared In
CCNode.hconvertToNodeSpaceAR:
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)worldPointAvailability
Declared In
CCNode.hconvertToWorldSpace:
Converts a Point to world space coordinates. The result is in Points.
- (CGPoint)convertToWorldSpace:(CGPoint)nodePointAvailability
Declared In
CCNode.hconvertToWorldSpaceAR:
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)nodePointAvailability
Declared In
CCNode.hconvertTouchToNodeSpace:
Converts a UITouch to node (local) space coordinates. The result is in Points.
- (CGPoint)convertTouchToNodeSpace:(UITouch *)touchAvailability
Declared In
CCNode.hconvertTouchToNodeSpaceAR:
Converts a UITouch to node (local) space coordinates. The result is in Points. This method is AR (Anchor Relative)..
- (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touchAvailability
Declared In
CCNode.hdraw
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)drawDeclared In
CCNode.hgetActionByTag:
Gets an action from the running action list given its tag
- (CCAction *)getActionByTag:(NSInteger)tagReturn Value
the Action the with the given tag
Availability
Declared In
CCNode.hgetChildByTag:
Gets a child from the container given its tag
- (CCNode *)getChildByTag:(NSInteger)tagReturn Value
returns a CCNode object
Availability
Declared In
CCNode.hintersectsNode:
Returns true if the node’s boundingBox intersects with the boundingBox of another node.
- (BOOL)intersectsNode:(CCNode *)otherDeclared In
CCNodeExtensions.hnodeToParentTransform
Returns the matrix that transform the node’s (local) space coordinates into the parent’s space coordinates. The matrix is in Pixels.
- (CGAffineTransform)nodeToParentTransformAvailability
Declared In
CCNode.hnodeToWorldTransform
Returns the world affine transform matrix. The matrix is in Pixels.
- (CGAffineTransform)nodeToWorldTransformAvailability
Declared In
CCNode.hnumberOfRunningActions
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)numberOfRunningActionsDeclared In
CCNode.honEnter
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)onEnterDeclared In
CCNode.honEnterTransitionDidFinish
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)onEnterTransitionDidFinishAvailability
Declared In
CCNode.honExit
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)onExitDeclared In
CCNode.honExitTransitionDidStart
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)onExitTransitionDidStartDeclared In
CCNode.hparentToNodeTransform
Returns the matrix that transform parent’s space coordinates to the node’s (local) space coordinates. The matrix is in Pixels.
- (CGAffineTransform)parentToNodeTransformAvailability
Declared In
CCNode.hpauseSchedulerAndActions
pauses all scheduled selectors and actions. Called internally by onExit
- (void)pauseSchedulerAndActionsDeclared In
CCNode.hremoveAllChildren
Removes all children from the container forcing a cleanup.
- (void)removeAllChildrenAvailability
Declared In
CCNode.hremoveAllChildrenWithCleanup:
Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
- (void)removeAllChildrenWithCleanup:(BOOL)cleanupAvailability
Declared In
CCNode.hremoveChild:
Removes a child from the container forcing a cleanup
- (void)removeChild:(CCNode *)childAvailability
Declared In
CCNode.hremoveChild: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)cleanupAvailability
Declared In
CCNode.hremoveChildByTag:
Removes a child from the container by tag value forcing a cleanup.
- (void)removeChildByTag:(NSInteger)tagAvailability
Declared In
CCNode.hremoveChildByTag: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)cleanupAvailability
Declared In
CCNode.hremoveChildrenInArray:cleanup:
remove all childs in the given CCArray or NSMutableArray (or any other collection supporting NSFastEnumeration)
- (void)removeChildrenInArray:(id<NSFastEnumeration>)childArray cleanup:(BOOL)cleanupDeclared In
CCNodeExtensions.hremoveFromParent
Remove itself from its parent node forcing a cleanup. If the node orphan, then nothing happens.
- (void)removeFromParentAvailability
Declared In
CCNode.hremoveFromParentAndCleanup:
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)cleanupAvailability
Declared In
CCNode.hreorderChild:z:
Reorders a child according to a new z value. The child MUST be already added.
- (void)reorderChild:(CCNode *)child z:(NSInteger)zOrderDeclared In
CCNode.hresumeSchedulerAndActions
resumes all scheduled selectors and actions. Called internally by onEnter
- (void)resumeSchedulerAndActionsDeclared In
CCNode.hrunAction:
Executes an action, and returns the action that is executed. The node becomes the action’s target.
- (CCAction *)runAction:(CCAction *)actionReturn Value
An Action pointer
Availability
Discussion
Warning: Starting from v0.8 actions don’t retain their target anymore.
Declared In
CCNode.hschedule:
schedules a selector. The scheduled selector will be ticked every frame
- (void)schedule:(SEL)sDeclared In
CCNode.hschedule: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)secondsDiscussion
If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
Declared In
CCNode.hschedule: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)delayDeclared In
CCNode.hscheduleOnce:delay:
Schedules a selector that runs only once, with a delay of 0 or larger
- (void)scheduleOnce:(SEL)selector delay:(ccTime)delayDeclared In
CCNode.hscheduleUpdate
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)scheduleUpdateAvailability
Declared In
CCNode.hscheduleUpdateWithPriority:
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)priorityAvailability
Declared In
CCNode.hsetPositionRelativeToParentPosition:
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)posDeclared In
CCNodeExtensions.hsortAllChildren
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)sortAllChildrenDeclared In
CCNode.hstopAction:
Removes an action from the running action list
- (void)stopAction:(CCAction *)actionDeclared In
CCNode.hstopActionByTag:
Removes an action from the running action list given its tag
- (void)stopActionByTag:(NSInteger)tagAvailability
Declared In
CCNode.hstopAllActions
Removes all actions from the running action list
- (void)stopAllActionsDeclared In
CCNode.htransferToNode:
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 *)targetNodeDeclared In
CCNodeExtensions.htransform
performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
- (void)transformDeclared In
CCNode.htransformAncestors
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)transformAncestorsAvailability
Declared In
CCNode.hunscheduleAllSelectors
unschedule all scheduled selectors: custom selectors, and the ‘update’ selector. Actions are not affected by this method.
- (void)unscheduleAllSelectorsAvailability
Declared In
CCNode.h