Tests Engineering Structure of self-learning cocos2d-x

Source: Internet
Author: User

In order to write the game, decided to learn cocos2d-x. If you are interested, please join us.

The MAC system, xcode environment, and windows are unavailable for the moment.

Enter the cocos2d-x source code directory, enter the tests directory, enter the prom. iOS directory, double-click test. xcodeproj to open the tests project. For example.

Tests. h defines the names of all test items, and testresource. h defines all image resources. Testbasic. h defines testscene. Its implementation file implements the main menu and its callback function. All the scene of the test option will inherit this class. Controller to build all the test options, is to enterProgramThe test list.

The following tests group contains the specific implementation of each test project.

Appdelegate is the program entry. See its definition:


This class needs to rewrite three methods, so you can understand what it is after reading the annotations. Let's look at its implementation.


CodeThe first step is to construct an example of the director class. Because ccdirector is a single-column mode (the Director can only have one), the standard call method is to use ccdirector: shareddire() to construct an instance. Just copy it when you use it.

The Director is responsible for a series of initialization work. Here there are only a few items (openglview, FPS ).

Then there is the scene and set (Layer ). Scenes are similar to shooting scenes in movies. Set scenes are many elements of scenes, such as the background layer, role layer, and NPC layer.

Therefore, call pscene-> addchild (player) to add a scene.

Finally, the Director started the command execution scenario. Pdirector-> runwithscene (pscene );

Next, let's look at each test instance.

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.