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.