CCPoolManagerIs a single class that manages multiple garbage collection objects. CCArray * m_pReleasePoolStack can manage multiple garbage collectors. CCPoolManager uses getCurReleasepool to obtain the current Garbage Collector m_pCurReleasePool. If m_pCurReleasePool = NULL, call push to create a new Garbage Collector and add it to the m_pReleasePoolStack. The Pop method clears the current Garbage Collector m_pCurReleasePool, and then releases a new setting for the stack pop to be used by the current garbage collector.
CCAutoreleasePoolThe automatic garbage collector manages added CCObject objects through a dynamic array autorelease.
CCApplicationIs the main application class of the Cocos2d-x, the application must inherit this CCApplication, in the main function need to define a CCApplication object and execute its run method.
CCDirectorThe director class is mainly used for scenario management and scheduling. It is initialized by creating CCActionManagement Object Manager, touch message distributor, Keyboard Message distributor, accelerator, and a series of other methods, the CCPoolManager that we just mentioned also needs to be used to create a garbage collector.
The most important method isMainLoopThis method is similar to the mainLoop in openGL and glut libraries. The steps are rendering scenarios. Release the current garbage collector, but it is implemented through CCPoolManager, while opengl is implemented through glClear.
CCNode class, which is the most important member method:
Create and release: onEnter (), onExit ()
Add and delete sub-objects: addchild (), removeChild ()
Return space of the rectangle: bounddingBox (void );
Run related actions: runAction (), runAllAction (), stopAction (), and so on.
There are also important rendering padding: draw (), visit (), transform ()
The custom drawing of the CCNote object must be implemented in the draw method, because the engine sets the status of the drawing environment in the context of the function call.
Scheduling mechanism: Add by registering the scheduler method, or use the CCNote: scheduleUpdate method.
First: in fact, it is actually implemented by calling the scheduler monomer, which is generated during CCDirector initialization and set in the CCNote constructor for CCNote.
The registration and scheduling of scheduling workers is mainly to create a timer CCTimer object and add the CCNote object and scheduler handler to the timer object for later scheduling.
Garbage collection mechanism:Similar to java's garbage collection mechanism, it is essentially a reference counting mechanism for the base class CCObject.
When CCObject is initialized, the reference count is set to 1. If retain is added, the release value is reduced by one.
In addition, the main task of mainLoop is to render the scenario, release and clear the current garbage through CCPoolManager (see the above running mechanism)