Analysis of cocos2dx engine directory

[Nagging]
Through the learning in the previous sections, I believe that everyone has already configured the VS+cocos2dx2.2.3 environment, and successfully ran the official case HelloWorld.

[3.x changes]
The engine catalog of 3.x has changed a lot, so it is listed separately.
Please move to: http://shahdza.blog.51cto.com/2410787/1549803

1. Spy on the file directory
If you want to learn cocos2dx well, you first need to understand the various files in the engine directory. Next, let us first analyze the file directory of the cocos2dx2.2.3 engine.
write picture description here

从目录中我们主要了解一下一下几个文件:

cocos2dx: The core part of the cocos2d-x engine, which stores most of the source files of the engine.
CocosDenshion: source files related to the sound module.
Debug.win32: Debug output directory on Windows.

extensions: The extension directory. Including some 2.5D effects, network control protocols, and some GUIs, etc. When using these extensions, you need to use namespace cocos2d::extension.
external: third-party directory library. It mainly includes Box2D, chipmunk physics engine, and sqlite3 light database.
samples: Official samples. Contains official examples of Cpp, Javascript, and lua. Among them, Cpp/HelloCpp is the simplest example. In addition, a TestCpp project is included, which covers the use of all classes of the cocos2dx engine, so it is very important!
scripting: scripting directory. Contains the relevant source files for javascript and lua. It can be ignored for those developed in C++ language.
Template: Template directory. Provides project templates for new cocos2dx projects created under various platforms and IDEs.
Tools: Tools directory. Provides script tools for creating new cocos2dx projects under various platforms.
build-win32.bat: Compile the windwos project script of the cocos2d-x engine.
cocos2d-win32.vc2010.sln: windows project vs2010 solution file.

2. Main engineering projects
in Cocos2dx In the cocos2d-win32.vc2010.sln solution we opened, we can see that the following five engineering projects are referenced.
write picture description here

libBox2D //cocos2d-x-2.2.3\external\Box2D\proj.win32
libchipmunk //cocos2d-x-2.2.3\external\chipmunk\proj.win32
libcocos2d //cocos2d-x-2.2.3\cocos2dx\proj.win32
libCocosDenshion //cocos2d-x-2.2.3\CocosDenshion\proj.win32
libExtensions //cocos2d-x-2.2.3\extensions\proj.win32

相信根据上面介绍的文件目录,也能知道这些事上面东西了吧。没错,就是cocos2dx引擎的主要五大工程源文件。在用python创建的新项目里,至少也需要将libcocos2d和libCocosDenshion工程项目添加到新项目的解决方案中,并且在 通用属性-> 框架和引用 中引用这些工程,才能运行新项目。

Third, the use of some commonly used cocos2dx header files

#include "cocos2d.h"                 //这个应该是每个项目中都比不可少的头文件吧? 比不可少!
#include "Box2D/Box2D.h"             //Box2d物理引擎
#include "SimpleAudioEngine.h"       //声音引擎
#include "cocos-ext.h"               //第三方库文件
using namespace cocos2d;             //cocos2d的命名空间
using namespace cocos2d::extension;  //使用扩展类需要包含的命名空间
using namespace CocosDenshion;       //声音引擎的命名空间

//Header file directory
cocos2d.h: cocos2d-x-2.2.3\cocos2dx\include
cocos2d.cpp: cocos2d-x-2.2.3\cocos2dx
SimpleAudioEngine.h: cocos2d-x-2.2.3\CocosDenshion\include
cocos- ext.h: cocos2d-x-2.2.3\extensions
Box2D, chipmunk, sqlite3: cocos2d-x-2.2.3\external
Reprint URL: http://blog.51cto.com/shahdza/1539452

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326684668&siteId=291194637