CocosNode Class Reference

#import <CocosNode.h>

Inherited by AtlasNode, AtlasSprite, AtlasSpriteManager, Layer, MenuItem, ParticleSystem, Scene, and TextureNode.

List of all members.

Public Member Functions

(id) - init
 initializes the node
(void) - onEnter
(void) - onExit
(id) - addChild:
(id) - addChild:z:
(id) - addChild:z:tag:
(id) - addChild:z:parallaxRatio:
(id) - add:
(id) - add:z:
(id) - add:z:tag:
(id) - add:z:parallaxRatio:
(void) - removeChild:cleanup:
(void) - removeChildByTag:cleanup:
(void) - removeAllChildrenWithCleanup:
(void) - remove:
(void) - removeByTag:
((deprecated) - __attribute__
(void) - removeAndStop:
(void) - removeAndStopByTag:
((deprecated) - __attribute__
(CocosNode *) - getChildByTag:
(CocosNode *) - getByTag:
((deprecated) - __attribute__
(void) - reorderChild:z:
(void) - draw
(void) - visit
(void) - transform
(void) - transformAncestors
(Action *) - do:
(Action *) - runAction:
(void) - stopAllActions
(void) - stopAction:
(void) - stopActionByTag:
(Action *) - getActionByTag:
(int) - numberOfRunningActions
(void) - schedule:
(void) - schedule:interval:
(void) - unschedule:
(CGAffineTransform) - nodeToWorldTransform
(CGAffineTransform) - worldToNodeTransform
(CGPoint) - convertToNodeSpace:
(CGPoint) - convertToWorldSpace:
(CGPoint) - convertToNodeSpaceAR:
(CGPoint) - convertToWorldSpaceAR:
(CGPoint) - convertTouchToNodeSpace:
(CGPoint) - convertTouchToNodeSpaceAR:

Static Public Member Functions

(id) + node
 creates a node

Properties

int zOrder
float rotation
float scale
float parallaxRatio
float parallaxRatioY
float parallaxRatioX
CGPoint position
Cameracamera
GridBasegrid
BOOL visible
CGPoint transformAnchor
CocosNodeparent
BOOL relativeTransformAnchor
int tag
NSArray * children


Detailed Description

CocosNode is the main element. Anything thats gets drawn or contains things that get drawn is a CocosNode. The most popular CocosNodes are: Scene, Layer, Sprite, Menu.

The main features of a CocosNode are:

Some CocosNodes provide extra functionality for them or their children.

Subclassing a CocosNode usually means (one/all) of:

Features of CocosNode:

Limitations:


Member Function Documentation

- ((deprecated) __attribute__  

Returns the absolute position of the CocosNode

Deprecated:
Use convertToWorldSpace:CGPointZero instead. Will be removed in v0.8
Returns:
a CGPoint value

- ((deprecated) __attribute__  

Removes all children from the container. It stops all running actions from the removed objects and unschedules all scheduled selectors

Deprecated:
Will be removed in v0.8. Use removeAllChildrenWithCleanup:YES instead

- ((deprecated) __attribute__  

Removes all children from the container.

Deprecated:
Will be removed in v0.8. Use removeAllChildrenWithCleanup:NO instead
Warning:
It DOESN'T stop all running actions from the removed object and it DOESN'T unschedules all scheduled selectors

- (id) add:  

Adds a child to the container with z-order as 0

Deprecated:
Will be removed in v0.8. Use addChild instead

- (id) add: (CocosNode *)  node  

Adds a child to the container with a z-order

Deprecated:
Will be removed in v0.8. Use addChild:z instead

- (id) add: (CocosNode *)  node
z: (int)  z 

Adds a child to the container with a z-order and a parallax ratio

Deprecated:
Will be removed in v0.8. Use addChild:z:tag:paralalxRatio instead

- (id) add: (CocosNode *)  node
z: (int)  z 

Adds a child to the container with z order and tag

Deprecated:
Will be removed in v0.8. Use addChild:z:tag instead

- (id) addChild: (CocosNode *)  node  

Adds a child to the container with z-order as 0. It returns self, so you can chain several addChilds.

Since:
v0.7.1

- (id) addChild: (CocosNode *)  node
z: (int)  z 

Adds a child to the container with a z-order It returns self, so you can chain several addChilds.

Since:
v0.7.1

- (id) addChild: (CocosNode *)  node
z: (int)  z
parallaxRatio: (CGPoint)  c 

Adds a child to the container with a z-order and a parallax ratio It returns self, so you can chain several addChilds.

Since:
v0.7.1

- (id) addChild: (CocosNode *)  node
z: (int)  z
tag: (int)  tag 

Adds a child to the container with z order and tag It returns self, so you can chain several addChilds.

Since:
v0.7.1

- (CGPoint) convertToNodeSpace: (CGPoint)  worldPoint  

converts a world coordinate to local coordinate

Since:
v0.7.1

- (CGPoint) convertToNodeSpaceAR: (CGPoint)  worldPoint  

converts a world coordinate to local coordinate treating the returned/received node point as anchor relative

Since:
v0.7.1

- (CGPoint) convertTouchToNodeSpace: (UITouch *)  touch  

XXX: needs documentation

Since:
v0.7.1

- (CGPoint) convertTouchToNodeSpaceAR: (UITouch *)  touch  

XXX: needs documentation

Since:
v0.7.1

- (CGPoint) convertToWorldSpace: (CGPoint)  nodePoint  

converts local coordinate to world space

Since:
v0.7.1

- (CGPoint) convertToWorldSpaceAR: (CGPoint)  nodePoint  

converts local coordinate to world space treating the returned/received node point as anchor relative

Since:
v0.7.1

- (Action*) do:  

Executes an action, and returns the action that is executed

Deprecated:
Will be removed in v0.8. Use runAction instead

- (void) draw  

override this method to draw your own node.

- (Action*) getActionByTag: (int)  tag  

Gets an action from the running action list given its tag

Since:
v0.7.1
Returns:
the Action the with the given tag

- (CocosNode*) getByTag:  

Gets a child from the container given its tag

Deprecated:
Will be removed in v0.8. Use getChildByTag instead
Returns:
returns a CocosNode object

- (CocosNode*) getChildByTag: (int)  tag  

Gets a child from the container given its tag

Returns:
returns a CocosNode object
Since:
v0.7.1

- (id) init  

initializes the node

+ (id) node  

creates a node

- (CGAffineTransform) nodeToWorldTransform  

actual affine transforms used XXX: needs documentation

Since:
v0.7.1

- (int) 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.

- (void) onEnter  

callback that is called every time the node enters the 'stage'

- (void) onExit  

callback that is called every time the node leaves the 'stage'.

- (void) remove:  

Removes a child from the container

Deprecated:
Will be removed in v0.8. Use removeChild:cleanup:NO instead
Warning:
It DOESN'T stop all running actions from the removed object and it DOESN'T unschedules all scheduled selectors

- (void) removeAllChildrenWithCleanup: (BOOL)  cleanup  

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

Since:
v0.7.1

- (void) removeAndStop:  

Removes a child from the container by reference and stops all running actions and scheduled functions

Deprecated:
Will be removed in v0.8. Use removeChild:cleanup:YES instead

- (void) removeAndStopByTag:  

Removes a child from the container by tag and stops all running actions and scheduled functions

Deprecated:
Will be removed in v0.8. Use removeChildByTag:cleanup:YES instead

- (void) removeByTag:  

Removes a child from the container given its tag

Deprecated:
Will be removed in v0.8. Use removeChildByTag:cleanup:NO instead
Warning:
It DOESN'T stop all running actions from the removed object and it DOESN'T unschedules all scheduled selectors

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

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

Since:
v0.7.1

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

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

Since:
v0.7.1

- (void) reorderChild: (CocosNode *)  child
z: (int)  zOrder 

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

- (Action*) runAction: (Action *)  action  

Executes an action, and returns the action that is executed. The target will be retained.

Warning:
in v0.8 the target won't be retained anymore
Since:
v0.7.1
Returns:
An Action pointer

- (void) schedule: (SEL)  s  

check whether a selector is scheduled. schedules a selector. The scheduled selector will be ticked every frame

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

schedules a selector with an interval time in seconds. If time is 0 it will be ticked every frame.

- (void) stopAction: (Action *)  action  

Removes an action from the running action list

- (void) stopActionByTag: (int)  tag  

Removes an action from the running action list given its tag

Since:
v0.7.1

- (void) stopAllActions  

Removes all actions from the running action list

- (void) transform  

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

- (void) transformAncestors  

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

Since:
v0.7.2

- (void) unschedule: (SEL)  s  

unschedule a selector

- (void) visit  

recursive method that visit its children and draw them

- (CGAffineTransform) worldToNodeTransform  

XXX: needs documentation

Since:
v0.7.1


Property Documentation

- (Camera *) camera [read, assign]

A Camera object that lets you move the node using camera coordinates. If you use the Camera then position, scale & rotation won't be used

- (NSArray*) children [read, assign]

An array with the children

- (GridBase *) grid [read, write, retain]

A Grid object that is used when applying Effects

- (float) parallaxRatio [read, write, assign]

The parallax ratio of the node. 1.0 is the default ratio

- (float) parallaxRatioX [read, write, assign]

The Y parallax ratio of the node. 1.0 is the default ratio

- (float) parallaxRatioY [read, write, assign]

The X parallax ratio of the node. 1.0 is the default ratio

- (CocosNode *) parent [read, write, assign]

A weak reference to the parent

- (CGPoint) position [read, write, assign]

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

- (BOOL) relativeTransformAnchor [read, write, assign]

If YES the transformtions will be relative to (-transform.x, -transform.y). Sprites, Labels and any other sizeble object use it. Scenes, Layers and other "whole screen" object don't use it.

- (float) rotation [read, write, assign]

The rotation (angle) of the node in degrees. 0 is the default rotation angle

- (float) scale [read, write, assign]

The scale factor of the node. 1.0 is the default scale factor

- (int) tag [read, write, assign]

A tag used to identify the node easily

- (CGPoint) transformAnchor [read, write, assign]

The transformation anchor point. For Sprite and Label the transform anchor point is (width/2, height/2)

- (BOOL) visible [read, write, assign]

Whether of not the node is visible. Default is YES

- (int) zOrder [read, assign]

The z order of the node relative to it's "brothers": children of the same parent


The documentation for this class was generated from the following file:

Generated on Tue Jun 9 10:39:33 2009 for cocos2d for iPhone 0.7.3 by  doxygen 1.5.8