The building blocks, nodes
In Cocos2d, everything you see on screen is a subclass of the CCNode
class. Even the scenes your game has are subclasses of the CCNode
class.
There are some important subclasses that will be used in almost every game. Therefore, it is important to know them. These are as follows:
CCSprite
: This represents an image that can be animatedCCNodeColor
: This is a plain colored nodeCCLabelTTF
: This is a node that renders text in any TrueType fontCCButton
: This is an interactive node that can have an action attachedCCLayoutBox
: This is a node that lays out other nodes in a vertical or horizontal layout
Tip
The CCLayoutBox
node replaces the CCMenu
class, which was in the previous versions of Cocos2d.
The reason every class inherits from the CCNode
class is that there are some important properties that all visible elements on-screen need. These are as follows:
contentSize
: This is the size of the element in the unit that is specified in thecontentSizeType
propertyposition
: This...