Cocos2s-x架构

本文详细介绍了Cocos2d-x与Cocos2d-html5的游戏开发框架架构及目录结构。包括核心组件、扩展功能、跨平台支持等内容,并提供了从入门到进阶的学习资源指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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:

Directory   Explain  
CocosDenshionAudio support. Note that BGM and short effects are using different OS API on android
cocos2dxMajor 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
documentYou can download doxygen, use it to open doxygen.config file in this document folder, then generate offline API docs by yourself
extensionsIf you looking for more GUI controls, network access, CocosBuilder support, and even 2.5D feature, that's it. using namespace cocos2d::extension
externalphysics libraries, box2d and chipmunk
licensescocos2d 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
scriptingYeah 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
templatetemplates 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
toolsscripts for binding c++ to lua, c++ to javascript
CHANGELOGwell, I don't know what does changelog mean. Can anyone who tell me please?
cocos2d-win32.vc2010.slnOpen with Visual Studio 2010. Note that VS2008 is not supported anymore since cocos2d-x v2.0
cocos2d-win32.vc2012.slnOpen with Visual Studio 2012
create-android-project.batRun it on windows. Please refer to How to create android project with script for usage
create-android-project.shRun it on linux and osx. Please refer to How to create android project with script for usage
install-templates-msvc.batAfter this installation, you can create empty cocos2d-x project in Visual Studios
install-templates-xcode.shAfter this installation, you can create empty cocos2d-x project in Xcode

2. Cocos2d-html5

2.1 Architecture

2.2 Directory Structure

CocosDenshionAudio support. Note that you need at least two audio formats to support all browsers
cocos2dMain directory, contains everything and maintains API the same as Cocos2d-x and Cocos2d-iPhone. The platform compatibility is well designed, enjoy it
box2dBox2dweb Physics engine v2.1a
chipmunkChipmunk Physic engine with no version number, ;)
DemoThere are couples demos which you may get started from them
extensionsIf you looking for more GUI controls, EditBox, CocosBuilder support, or any third party libs, that's where it is
HelloHTML5WroldAn advance Hello World for you to get started
libIt contains a min version engine when you run /cocos2d/build.xml with ant tool to package all engine flies to a single file
licensesCocos2d depends on many other open source projects. All of their licenses are here
samplesYou can find all classes usage in Tests. All the tests can be run in JSB. IMPORTANT. This is where you should start from
templatetemplates for creating a new Cocos2d-html5 project
toolsJSDoc and Closure Compiler
index.htmlIndex of Cocos2d-html5
AUTHORSList of all contributors
CHANGELOGWell, 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:

  1. native app on cocos2d-x + SpiderMonkey, which can parse javascript code into C.
  2. 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:

  1. Much faster coding speed than c++
  2. Don't need to deal with wild pointers / reference count / memory leak
  3. Crossing both native and web

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值