Architecture and Directory Structure
1. Cocos2d-x
1.1 Architecture
1.2 Directory Structure
After you download cocos2d-x repo from github, or unzip a stable release zip ball, you will see the directory structure like this:
CocosDenshion | Audio support. Note that BGM and short effects are using different OS API on android |
cocos2dx | Major directory, involves everything except cash. Sorry I'm wrong, some 2dx games earns +2 million dollars per month. So it should involves money. The platform adapter is well designed, enjoy it |
document | You can download doxygen, use it to open doxygen.config file in this document folder, then generate offline API docs by yourself |
extensions | If you looking for more GUI controls, network access, CocosBuilder support, and even 2.5D feature, that's it. using namespace cocos2d::extension |
external | physics libraries, box2d and chipmunk |
licenses | cocos2d depends on many other open source projects. All of their licenses are here |
samples | IMPORTANT. This is where you should start from. Cpp/HelloCpp is your first lesson, and you can find all classes usage in TestCpp. Looking for lua and js samples? They're also here |
scripting | Yeah I know, you hate c++, it's too complicated. No problem, Lua and Javascript is ready. Scripting folder includes lua official engine, and SpiderMonkey which we pick up from FireFox |
template | templates for creating cocos2d-x new project in different IDEs and various platforms. I don't know if there're such many IDEs and OS platforms on Mars |
tools | scripts for binding c++ to lua, c++ to javascript |
CHANGELOG | well, I don't know what does changelog mean. Can anyone who tell me please? |
cocos2d-win32.vc2010.sln | Open with Visual Studio 2010. Note that VS2008 is not supported anymore since cocos2d-x v2.0 |
cocos2d-win32.vc2012.sln | Open with Visual Studio 2012 |
create-android-project.bat | Run it on windows. Please refer to How to create android project with script for usage |
create-android-project.sh | Run it on linux and osx. Please refer to How to create android project with script for usage |
install-templates-msvc.bat | After this installation, you can create empty cocos2d-x project in Visual Studios |
install-templates-xcode.sh | After this installation, you can create empty cocos2d-x project in Xcode |
2. Cocos2d-html5
2.1 Architecture
2.2 Directory Structure
CocosDenshion | Audio support. Note that you need at least two audio formats to support all browsers |
cocos2d | Main directory, contains everything and maintains API the same as Cocos2d-x and Cocos2d-iPhone. The platform compatibility is well designed, enjoy it |
box2d | Box2dweb Physics engine v2.1a |
chipmunk | Chipmunk Physic engine with no version number, ;) |
Demo | There are couples demos which you may get started from them |
extensions | If you looking for more GUI controls, EditBox, CocosBuilder support, or any third party libs, that's where it is |
HelloHTML5Wrold | An advance Hello World for you to get started |
lib | It contains a min version engine when you run /cocos2d/build.xml with ant tool to package all engine flies to a single file |
licenses | Cocos2d depends on many other open source projects. All of their licenses are here |
samples | You can find all classes usage in Tests. All the tests can be run in JSB. IMPORTANT. This is where you should start from |
template | templates for creating a new Cocos2d-html5 project |
tools | JSDoc and Closure Compiler |
index.html | Index of Cocos2d-html5 |
AUTHORS | List of all contributors |
CHANGELOG | Well, it lists changes that above guys have done |
3. Javascript Binding
Crossing platform is good, but not good enough. Programming in C++ is super slow, in the other hand, C++ code cannot run on web browsers. That's why we add javascript binding. We can pack javascript code into:
- native app on cocos2d-x + SpiderMonkey, which can parse javascript code into C.
- web app on cocos2d-html5
We have a same API set on cocos2d-iphone, cocos2d-x and cocos2d-html5. Therefore, we can create 100% javascript game natively in cocos2d-x/cocos2d-iphone. When you want to run it on browsers, want you need is only switch engine to cocos2d-html5, without modifying your source code.
The benefits are:
- Much faster coding speed than c++
- Don't need to deal with wild pointers / reference count / memory leak
- Crossing both native and web
相关推荐
《Cocos2d-x 3.x游戏开发之旅》是一本深度探讨Cocos2dx 3.x框架的游戏开发专著,适合对游戏编程有兴趣并有一定基础的开发者。Cocos2dx是一个开源的游戏开发框架,它基于C++,同时支持多种语言,如Lua和JavaScript,...
cocos2d-x的架构设计十分精巧,主要由以下几个关键部分组成: 1. **Scene和Layer**:Scene代表游戏中的一个场景,可以理解为游戏的一帧或一个屏幕。Layer则是在Scene中展示内容的基本单位,可以包含多个Layer来组织...
首先,理解Quick-Cocos2dx的基本架构是至关重要的。Quick-Cocos2dx基于Cocos2d-x,提供了一层面向对象的C++接口,同时也支持使用Lua作为脚本语言。它的设计目标是使C++和Lua之间的交互变得简单,这样开发者可以在Lua...
### 使用Cocos2dx集成第三方.so库详解 #### 一、引言 在游戏开发过程中,经常需要使用到各种第三方库来实现特定的功能或者优化性能。对于基于Cocos2dx的游戏开发而言,集成第三方的.so动态链接库是常见的需求之一。...
网络游戏通常采用客户端-服务器(Client-Server,C/S)架构,前端负责用户界面和部分游戏逻辑,后端负责服务器计算和数据存储。两者通过网络进行通信,实现玩家间的互动和游戏状态同步。 1. **登录注册**:客户端...
常见的游戏引擎有Unity、Unreal Engine、Cocos2d-x等,它们大大简化了游戏开发流程,让开发者可以专注于游戏内容和玩法的设计。游戏引擎还包含了一些用于优化性能的工具,如资源管理、内存分配和多线程支持。 ...
软件框架如Unity、Unreal Engine、Cocos2d-x等,都内置了网络模块,允许开发者创建多人在线游戏。例如,Unity的Unity Networking系统,通过UNet API提供了一整套网络同步解决方案,包括对象状态同步、玩家控制、...
**Android游戏开发实例**:这部分可能包含使用Android游戏框架(如Unity、Unreal Engine或Cocos2d-x)开发游戏的实例,讲解游戏逻辑、物理引擎、碰撞检测、动画效果以及如何实现游戏得分和排行榜等功能。同时,也会...