CCNode is the main element. Anything that 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 scaled (scale) -# 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) -# The node will be scaled (scale) -# 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.