- CCNode is the base class for all renderable objects in Cocos2d
- CCNode is the main element of Cocos2d
- CCNode is the main class of Cocos2d
- In Cocos2d anything that gets drawn or contains things that get drawn is a CCNode
- Most objects in Cocos2d inherit from CCNode
For example, CCSpite is a subclass of CCNode. So, CCSprite has the all properties that the CCNode has.
In other words, A CCSprite is a CCNode with a PNG on it, a button (CCMenuItemSprite) is a CCNode with a PNG and clickable, a CCMenu is a CCNode with little clickable CCNode in it.
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)
- Camera ( using spherical coordinates )
- GridBase (to do mesh transformations)
- anchor point
- size
- visible
- z-order
- openGL z position
Limitations:
- A CCNode is a "void" object. It doesn't have a texture
CCNode *aNode = [CCNode node];
[self addChild:aNode];
aNode.position = CGPointMake(220,340);
aNode.rotation = 75;
aNode.scale = .7;
CCNode *anotherNode = [CCNode node];
[aNode addChild:anotherNode];