如何将两个cocos2D项目组合到一个应用程序? [英] How to combine two cocos2D projects to one app?

查看:230
本文介绍了如何将两个cocos2D项目组合到一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了两个不同的游戏(两个不同的项目),我已被分配到组合/合并到一个应用程序。所以我很困惑我应该遵循的方式,我应该把Game2添加到Game1作为第三方库,还是有一种方法可以在运行时更改目标?

I have developed two different games (two different projects), I have been assigned to combine/ merge them to one app. So I am confused about the way that I should follow, should I just add Game2 to Game1 as a third party library or is there a way to change the target at the runtime?

简单

点击Button 1 ----->运行Game1的 MainScene

Click Button 1 -----> run Game1's MainScene

点击Button 2 ----->运行Game2的 MainScene

Click Button 2 -----> run Game2's MainScene

Xcode 4.2如何将一个项目包含到另一个项目中?

Followed this Xcode 4.2 how include one project into another one? question and added Game 2 to Game 1 like a static library.

这是两个游戏有很多相互头文件,如 MainScene, GameHud,Objects,Points ......

The thing is two game has lots of mutual headers ,like MainScene,GameHud,Objects,Points......

游戏1使用[director runWithScene:[MainMenu scene]
如何在点击按钮上调用Game2的MainScene?

Game 1 runs with [director runWithScene:[MainMenu scene]]; How can I call Game2's MainScene on click button?


是否可以在运行时更改目标?

推荐答案

p>这基本上只是咕噜工作。静态库不会帮助你太多,因为它不能解决冲突 - 类名在可执行文件中必须是唯一的。

It's basically just grunt work. A static library won't help you much because it doesn't resolve the conflicts - class names must be unique in an executable.

基本上你需要做的是将所有源代码和资源添加到同一个Xcode项目中。然后最初只是加载两个游戏之一,以试图让另一个编译。你必须重命名类和文件才能完成。

Basically what you need to do is to add all the source code and assets to the same Xcode project. Then initially just load one of the two games in order to try to get the other to compile. You'll have to rename classes and files to accomplish that.

完成后,添加一些(临时)选择菜单,以便在两个游戏之间进行选择。这可能会触发其他编译错误。

When that's done add some (temporary) selection menu of some kind so you can choose between the two games. This might trigger additional compile errors. Resolve them.

如果您的资产名称相同,但内容不同,则需要重命名并更改代码。

If you have assets of the same name but with different content you need to rename them and change the code.

然后测试并找到1000个小细节,让你拉你的头发。那么,至少他们中的一些肯定会是一个挑战。但对于那些挑战,Stackoverflow是。 :)

Then test and find the 1000 little details that'll make you pull your hair out. Well, at least some of them will be a challenge for sure. But for those challenges Stackoverflow was made. :)

这篇关于如何将两个cocos2D项目组合到一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆