The Node Class
This class is the base class for some of the most important classes that allow us to show something on the screen (Layer, Sprite, Label, Menu, etc…). It also is the base class for the Scene Graph elements (Scene) that allow us to switch from one scene to another in our game (More on this in later posts…).
The main features of Node class are:
- They can contain other Node object as their children
- They can schedule periodic function calls (callbacks) to allow us to change their attributes over time.
- They can execute actions (Action) to lets say move them around in a certain time.
The node class itself doesn’t draw anything on the screen as is, but we can inherit from this class and override its draw virtual method to draw things on the screen OR just use the Sprite class instead. According to the class reference document, subclassing a Node usually means:
- overriding init method to initialize resources and schedule callbacks
- create callbacks to handle the advancement of time
- overriding draw method to render the node
Node objects also have these useful properties: position, scale, rotation, anchor point, contentSize, visible.