Deluxe Edition aircraft war series (2)

Source: Internet
Author: User

The previous article introduced the general situation of the game. This article will start with the various files in the game.

Let's take a look at one of cocos2d-x 3.0's awesome features, which is much more exciting than before 3.0. Although 3.0 has been out for a long time, I still talk about this function, and I know that it is too good.

For the development of mobile games with cocos2d-x in different environments, the screen size is a relatively painful problem, such as before 3.0, In the code to modify the screen size is more troublesome, in addition, running a good size on the computer makes the mobile phone end feel a little worse.

Appdelegate. cpp is the entrance program for the entire game. The main code for setting the game size before 3.0 is as follows:

bool AppDelegate::applicationDidFinishLaunching() {// initialize directorauto director = Director::getInstance();auto glview = director->getOpenGLView();if (!glview) {glview = GLView::create("My Game");director->setOpenGLView(glview);}director->setOpenGLView(glview);#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)// a bug in DirectX 11 level9-x on the device prevents ResolutionPolicy::NO_BORDER from working correctlyglview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::SHOW_ALL);#elseglview->setDesignResolutionSize(288, 512, ResolutionPolicy::SHOW_ALL);#endifdirector->setDisplayStats(true);director->setAnimationInterval(1.0 / 60);auto scene = LoadingScene::create();director->runWithScene(scene);return true;}



The main code is:

glview->setDesignResolutionSize(288, 512, ResolutionPolicy::SHOW_ALL);

The configured size is 288 in width and 512 in length. The effect in Ubuntu is not particularly good, mainly because the two sides are black and only the middle is the display of the game screen.

In 3.0, you can directly set the glview size in the code, that is, the size of the game screen drawn,

Similarly, the applicationdidfinishlaunching () function in appdelegate. cpp is as follows:

bool AppDelegate::applicationDidFinishLaunching() {    // initialize director    auto director = Director::getInstance();    auto glview = director->getOpenGLView();    if(!glview) {        glview = GLView::createWithRect("My Game",Rect(0,0,320,480));        director->setOpenGLView(glview);    }    director->setDisplayStats(false);    director->setAnimationInterval(1.0 / 60);    auto scene = GameLayer::createScene();    director->runWithScene(scene);    return true;}


I feel much clearer. The point is
 glview = GLView::createWithRect("My Game",Rect(0,0,320,480));
You can directly set the drawing size of glview to 320*480, rect (320,480,) to set the coordinates and length and width of the drawn rectangle. The coordinates are () and the length is: 480, width, 320

For example, the image in the previous article is a game image running under the Linux naming terminal,


I usually test the game on a mobile phone after I write the game on a computer. running the game on a computer is much faster than on a mobile phone, and I can directly operate the terminal, compilation speed is faster than eclipse.

The main code in appdelegate. cpp is in the applicationdidfinishlaunching () function. The gamelayer scenario is generated in the function, and then the director class is called to run the scenario.

Well, this article mainly introduces some changes in appdelegate, and introduces the gamelayer layer of the game, that is, the main logic layer of the game. Next we will introduce the various genie elements and layers in the game.



Deluxe Edition aircraft war series (2)

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.