cocos2d cocos2d-x的开发

本文分享了作者在学习Cocos2d-X游戏引擎过程中的经验,包括Cocos2d与Cocos2d-X的区别、多平台平移的稳定性、安装与使用教程等关键信息,旨在帮助初学者快速入门并实作游戏。

今天仍然在学习cocos2d的开发,之前接触过一个ipad客户端应用的项目,现在由于工作需要,要做个游戏。定好了采用cocos2d。现在在学习中。今天看到一个朋友说要坚持写博客。记录下学习过程,也会增加和别人交流的机会。我就开始了。

 

第一先说下 cocos2d 和 cocos2d-x 其实但就学习来说他俩几乎没区别。前者是用objective-c写的,后者是用c++写的。前者的优势是易于使用,编写习惯对ios客户端开发者来说也好;后者的优势是多平台,方便平台间的平移。具体我还没做过实际的项目。希望大家不要太纠结这个东西。下面引用下我参考的文章吧。

 

      这里还有三点要说下:

     第一:现在很多游戏公司都趋向于Cocos2d-X引擎开发游戏的趋势,不得不说Cocos2d-X多平台平移确实很诱惑人,Cocos2d-X已成熟!

    第二:不少童鞋肯定会很想知道Cocos2d-X能多平台平移,那么平移稳定性如何?

        通过我的了解,Cocos2d-X开发都会使用统一的C++语言开发,例如在iOS开发中使用Xcode+cocos2d-X,在Android上一般使用Eclipse+Android NDK+ADT....

        其实总结一句,Cocos2d-iphone并不像很多童鞋认为的只要的一人开发就可打包多平台包这样子~ 如果说用一句话更贴切的形容Cocos2d-X,我会用“Cocos2d-X代码通用”来形容;

        从CC(CocoChina)上我看到王哲walzer(cocos2d-x 游戏引擎作者)在回复一童鞋问题时候这么说的:

       问:关于如何打包cocos2d-x程序的问题   本人新手,想请教一下如何将Cocos2d-x win32的程序打包成iphone能够运行的程序,请各位大大不吝赐教!谢谢!

      王哲walzer 答:win32上只是让你调试方便,要发布到appstore上,你还是得有个mac机,装好cocos2d-x template,新建工程,然后把win32上代码拷过来,手工地加入xcode工程里面,编译运行

 

 

然后说下需要的东西:mac系统的苹果电脑,一部苹果手机,当然是必须的了。还有安装好xcode。然后就要安装cocos2d模板了。

其实也很简单。下载地址是:https://code.google.com/p/cocos2d-iphone/downloads/list 找稳定版本的下载,后面标有 “featured”的。

 

下载后,放到你喜欢的位置上。然后打开终端。

这里先假设你下载后放的目录是/Downloads/

 

在终端里输入 sudo /Downloads/cocos2d-iphone-2.1/install-templates.sh

也可以在命令后面加 “-f” 来覆盖更新,可以通过这种方式来升级版本。不过你放心,他不会影响已存在的cocos2d项目的。

 

然后你再创建项目的时候就会发现左侧列表里多了一个cocos2d 的选项。

接下来你就可以创建个HelloWorld试试了。

 

cocos2d-x的安装其实也差不多,

下载地址是:https://code.google.com/p/cocos2d-x/downloads/list

 

也是进入到下载的目录,或者用全路径执行命令:sudo ./install-templates-xcode.sh

然后有如下提示

select the template version to install  

3 for xcode3  

4 for xcode4  

input nothing for all  

4  



 

按需引入<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Ant Design Vue 纯HTML项目示例</title> <!-- 引入Ant Design Vue的CSS --> <link rel="stylesheet" href="https://unpkg.com/ant-design-vue@3.2.21/dist/antd.css"> <!-- 引入Ant Design X Vue的CSS --> <link rel="stylesheet" href="https://unpkg.com/ant-design-x-vue@1.0.0/dist/antdx.css"> <!-- vue3引入 --> <script src="https://unpkg.com/dayjs/dayjs.min.js"></script> <script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script> <script src="https://unpkg.com/dayjs/plugin/weekday.js"></script> <script src="https://unpkg.com/dayjs/plugin/localeData.js"></script> <script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script> <script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script> <script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script> <script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script> <!-- vue3 --> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <!-- antdv --> <script src="https://cdn.jsdelivr.net/npm/ant-design-vue@4.2.6/dist/antd.min.js"></script> <!-- antdxv --> <script src="https://cdn.jsdelivr.net/npm/ant-design-x-vue@1.2.7/dist/index.umd.min.js"></script> </head> <body> <div id="app"></div> <script> const { createApp, ref, computed } = Vue; const { Button } = antd; const { Bubble, XProvider } = antdx; createApp({ template: ` <AXProvider :theme="{ algorithm: myThemeAlgorithm, }"> <div :style="{ padding: &#39;24px&#39;, backgroundColor: bgColor, }"> UMD <AXBubble content="hello bubble"></AXBubble> <AButton type="primary" @click="setLightTheme">Light</AButton> <AButton type="primary" @click="setDarkTheme">Dark</AButton> </div> </AXProvider> `, setup() { const { theme } = antd; const bgColor = ref("white"); const myThemeAlgorithm = ref(theme.defaultAlgorithm); const setLightTheme = () => { myThemeAlgorithm.value = theme.defaultAlgorithm; bgColor.value = "white"; }; const setDarkTheme = () => { myThemeAlgorithm.value = theme.darkAlgorithm; bgColor.value = "#141414"; }; return { myThemeAlgorithm, bgColor, setLightTheme, setDarkTheme }; } }) .use(XProvider) .use(Button) .use(Bubble) .mount("#app"); </script> <style> .container { max-width: 1200px; margin: 24px auto; padding: 0 16px; } .search-form { margin-bottom: 24px; padding: 16px; background-color: #f5f5f5; border-radius: 4px; } .user-table { margin-top: 16px; } .mb-6 { margin-bottom: 24px; } .mt-2 { margin-top: 8px; } </style> </body> </html>
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值