Ccctor ctor for coco2d-x Core

Source: Internet
Author: User

CCDriector is the core of the coco2s-x, used to create and control the display of the main screen, while controlling the scene display time and display mode. Generally, there is only one CCDirector in the game.

Role :? Initialize the OpenGL session.
? Set parameters and methods of OpenGL.
? Access and change the configuration details of the scenario and access Cocos2D-x.
? Access view.
? Set projection and orientation

Call method: CCDirector: shareddire()-> function name

Instance: Open the instance in the previous section and find and open AppDelegate. cpp. The code is roughly as follows:

Bool AppDelegate: applicationDidFinishLaunching () {// initialize director initialize CCDirector * pDirector = CCDirector: shareddire ();
// Set the openGl view pDirector-> setOpenGLView (CCEGLView: sharedOpenGLView (); // turn on display FPS whether to display the time per frame pDirector-> setDisplayStats (true ); // set FPS. the default value is 1.0/60 if you don't call this sets the time of each frame pDirector-> setAnimationInterval (1.0/60); // create a scene. it's an autorelease object creation scenario CCScene * pScene = HelloWorld: scene (); // run the scenario pDirector-> runWithScene (pScene); return true ;}
// The Work of the director when the game enters the background or returns from the background
// This function will be called when the app is inactive. When comes a phone call,it's be invoked toovoid AppDelegate::applicationDidEnterBackground(){    CCDirector::sharedDirector()->stopAnimation();    SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();}
// this function will be called when the app is active againvoid AppDelegate::applicationWillEnterForeground(){    CCDirector::sharedDirector()->startAnimation();    SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();}

 

 

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.