Analysis of cocos2d-x Hello World

Source: Internet
Author: User

Cocos2d-x Hello world analysis entry

* *********************************** Please specify the source: bytes ********************************************

 

Digress: I just got home yesterday afternoon, and you know that...

 

 

 

Body:

 

Well, the last back to build a Cocos2d-x environment, now open it to play.

This article is an analysis of the depth of wood ~.~

Open the created file with vs2012 and find the following content:

The first three are additional class libraries:

Libaudio audio and audio database

Libchipmunk chipmunk physical engine support library

Libcocos2d cocos2d-x Core Engine Library

 

Then, mygame's own project

There are four parts:

1. Put the classes in our files, and write your own classes ~

2. Resource puts our resource files, music and images used in the game. Originally, game. RC is a resource file format such as bitmap stored by VC.

To add a resource, you can place the resource in the resource folder of your project, even if the Resource Directory does not have this resource. The image is preferably in PNG format.

3. Win32 program call entry.

4. What other classes or items are called in the external dependency

 

 

Take a look at the two classes in the classes folder, one appdelegate and one helloworldscene.

First, appdelegate is the entry class of the program. The mian function of Win32 calls appdelegate.

Then, appdelegate is mainly responsible for some basic functions of the application:

When the program is loaded, call the function: applicationdidfinishlaunching ()

When a call arrives, the program enters the background and calls the function: applicationdidenterbackground ()

When the process ends, the program recovers and calls the function: applicationwillenterforeground ()

 

 

The second category, as its name implies, is the scenario class. It shows a scenario where the content is similar to images, exit buttons, and necessary helloworld.

This class is a layer that is initialized using the init method,

The layer contains the buttons closeitem, text label, and Sprite.

Each has a common definition:

1. Create

2. Location setposition

3. Add to layer addchild

Of course, this is only the general situation. There are some special cases, such as buttons, the added menu, and the callback function (that is, click this button to execute the content)

 

Well, this is the case for the moment ~.~

One small step every day, slowly accumulating.

 

 

* *********************************** Please specify the source: bytes ********************************************

 

 

 

 

 

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.