CCScene and CClayer in core coco2d-x

Source: Internet
Author: User

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:

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.