1

我正在使用 cocos2D 开发 iOS 游戏。由于预算限制,我们没有资源来创建定制的 iPad 版本,但我们仍然希望为 iPad 用户提供一种无需升级所有内容即可体验游戏的方式。

因此,我尝试采用以下方法:

通过创建 -hd 图形并在 320x480 的点坐标空间中工作,我在开发这款游戏时考虑了 iPhone4。我想通过重新定义 EAGLView 来创建 iPad 版本,使其边界为(64、32、640、960),设计一个填充剩余空间的自定义框架图稿,加载 -hd 图形但保持点坐标系为 320x480 .

我试过弄乱 contentScaleFactor 并尝试创建一个 scale = 2 的自定义基础 CCScene,但我发现这两种方法都不是最优的。我知道我可以通过设备检测和宏手动转换任何位置,但我最好保留每个坐标原样。

有没有人熟悉 cocos2D 源代码,可以为我指明正确的方向,比如我应该在哪里修改源代码来解决我的问题?

4

2 回答 2

1

You do a device check in the appdelagate and this is where you can specify to run specific things like higher res graphics or different code based on the platform.

It's not that hard to port an app to the iPad... if you use points and not pixels in your application code. There are several methods to use high res graphics for the iPhone 4 and the iPad. Sounds like you have the right approach if you have no budget for the iPad version.

For me the time to develop the iPad version of my game was six months. The iPhone version was 1 week. The code base is the same you just have to tweek some things like Retina displays and some graphics. But the majority of the code will not change.

Are you sure you don't want to make it for both? It's not that hard or costly! I would develop the iPad version first then scale down for the iPhone... It's easier to "Design Big" then scale down then it is to scale up... especially graphics! Just saying...

于 2011-06-10T19:51:27.883 回答
0

我认为你最好的选择是通过你的应用程序并抽象出你的 iPhone 游戏的定位数学,以便你可以为 iPad 和 iPhone 提供它。例如,如果您在代码中硬编码了位置,请将它们替换为变量,然后使用 iPad 和 iPhone 的条件编译 #define 它们,或者在 init() 中从屏幕范围计算它们。这将有一个额外的好处,即可以轻松支持未来出现的任何其他新形式因素(并且无论如何可能是一个好习惯,因为“幻数”是一种反模式,可以让你的代码变得简单打破)。

于 2011-02-16T16:56:10.153 回答