使用cocos2D创建带框架的iPad版本

发布于 2024-10-17 14:25:44 字数 449 浏览 5 评论 0原文

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

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

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

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

有熟悉 cocos2D 源代码的人可以指出我应该在哪里修改源代码以解决我的问题的正确方向吗?

I'm developing an iOS game using cocos2D. Because of budget constrains we don't have the resources to create a custom iPad version but we'd still like to offer iPad users a way to experience the game without having to upscale everything.

I'm therefore trying to take the following approach:

I've developed the game with iPhone4 in mind by creating -hd graphics and working in the point coordinate space of 320x480. I want to create the iPad version by redefining the EAGLView so its boundary is (64, 32, 640, 960), designing a custom frame artwork that fills up the remaining space, loading the -hd graphics but keeping the point coordinate system to 320x480.

I've tried messing with contentScaleFactor and I've tried creating a custom base CCScene with scale = 2 but I find neither approach optimal. I know I could manually convert any position by device detection and a macro but I would preferably leave every coordinate as it is.

Is anyone familiar with the cocos2D source that could point me in the correct direction as with where I should modify the source to solve my problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

述情 2024-10-24 14:25:44

您可以在 appdelagate 中进行设备检查,在这里您可以指定运行特定的内容,例如更高分辨率的图形或基于平台的不同代码。

如果您在应用程序代码中使用点而不是像素,那么将应用程序移植到 iPad 并不难。有多种方法可以在 iPhone 4 和 iPad 上使用高分辨率图形。如果您没有 iPad 版本的预算,听起来您的方法是正确的。

对我来说,开发 iPad 版游戏的时间是六个月。 iPhone版本为1周。代码库是相同的,你只需要调整一些东西,比如视网膜显示器和一些图形。但大部分代码不会改变。

你确定不想两者兼而有之吗?这并不困难或昂贵!我会先开发 iPad 版本,然后缩小 iPhone 版本...“设计大”然后缩小然后放大更容易...尤其是图形!只是说...

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...

软的没边 2024-10-24 14:25:44

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

I think your best bet would be to go through your app and abstract out the positioning math for your iPhone game so that you can provide it for iPad and iPhone. For instance, if you've hardcoded positions in your code, replace them with variables, and either #define them with conditional compilation for iPad and iPhone, or compute them in init() from the screen extents. This would have the added benefit of making it easy to support any other new form factors that come out in the future (and is probably a good habit to get into anyway, since "magic numbers" is an anti-pattern that makes your code easy to break).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文