I. CCScene
CCScene is a subclass of CCNode. It has one more feature than CCNode: it is used for its own anchor and is located in the center of the screen. In fact, it is just an abstract concept, essentially a CCNode
Define a new CCScene instance:
CCScene* HelloWorld::scene(){ CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object HelloWorld *layer = HelloWorld::create(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene;}Obtain and run CCScene
// create a scene. it's an autorelease object CCScene *pScene = HelloWorld::scene(); // run pDirector->runWithScene(pScene);
Ii. CCLayer)
CCLayer is a subclass of CCNode. All functions of CCNode can be implemented and input can be processed (including touch screen and acceleration sensor), because CCLayer implements TouchEventsDelegate, acceleration Sensor proxy protocol, keyboard time proxy protocol, etc. The inheritance relationship of CCLayer is as follows: