带有 ARC 的新 iPhone cocos2d 项目

发布于 2024-12-28 09:50:51 字数 622 浏览 5 评论 0原文

使用 Xcode 4.2 和 cocos2d 开始一个新项目。我想在我的代码中使用 ARC 并将 cocos2d 作为静态库链接。

从github下载cocos2d并安装新模板。

创建了一个新的 cocos2d 项目,但是 Xcode 没有在第二个对话框上显示通常的 ARC 复选框。

我假设这是因为模板是 Xcode 3 模板?

任何对此的想法将不胜感激。

感谢

更新,

自从我发布此文以来,我下载了 cocos2d v2 并设法使用 cocos2d 作为静态库来编译 hello world。该项目是使用 cocos2d 模板创建的,看起来它设置为在“构建设置”中使用 LLVM comp v3,但没有 ARC,这是预期的,因为模板没有给我 ARC 复选框。

我运行了 ARC 重构,并在 AppDelegate(.h 和 .m)、HelloWorldLayer.m 和 main.m 中需要修复一些问题,它们仍然是 ARC 之前的版本。

这告诉我 v2 cocos2 模板尚未更新,这很奇怪,因为 v2 应该是 ARC 的。

我错过了什么吗?我应该使用不同的模板吗?

Kobold2d 听起来很酷,但是有快速入门指南吗?

谢谢

starting on a new project with Xcode 4.2 and cocos2d. I'd like to use ARC in my code and link cocos2d in as a static library.

Downloaded cocos2d from github and installed the new template.

Created a new cocos2d project however Xcode is not showing the usual ARC checkbox on the second dialogbox.

I'm assuming this is because the templates are Xcode 3 template?

Any thought on this would be appreciated.

thanks

UPDATE

since i posted this i downloaded cocos2d v2 and managed to compile the hello world with cocos2d as a static lib. the project was created using the cocos2d template and looks like it is set to use the LLVM comp v3 in 'Build Settings' but without ARC which is expected since the template did not give me the ARC checkbox.

I ran the Refactor to ARC and a few things needed fixing in the AppDelegate (.h & .m), the HelloWorldLayer.m and main.m which is still pre-ARC.

This tells me that the v2 cocos2 templates have not been updated and that's weird since v2 is supposed to be ARC'ed.

Am I missing something? should i be using different templates?

Kobold2d sound cool but is there a quick start guide?

thanks

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

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

发布评论

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

评论(3

风吹短裙飘 2025-01-04 09:50:51

如果您想将 cocos2d-iphone 与 ARC 一起使用,请考虑使用 Kobold2D。默认情况下,每个项目都启用 ARC,您不必squat,只需安装并开始编码即可。由于它是默认选项,因此您可以确定 Kobold2D 中的 cocos2d-iphone(改进版)版本经过了 ARC 良好的测试,并且包含一些额外的 ARC 修复。

Cocos2D 从 v1.0.1 / 1.1 beta 和 2.0 beta2 开始不支持开箱即用的 ARC(没有启用 ARC 的模板项目可用)。此Tiny Tim 游戏教程这个 Ray Wenderlich 教程教您如何正确设置 cocos2d-iphone 以构建为静态库,以便您可以为项目代码启用 ARC。

您没有看到 ARC 作为选项的可能原因:

  • 该项目未设置为使用
  • 您正在寻找 ARC 的“Apple LLVM Compiler 3.0”,但构建设置实际上名为“Objective-C 自动引用计数”

请注意据我所知,cocos2d-iphone 1.0.1(当前稳定版本)与 ARC 不兼容,但我相信 v1.1 beta 已经添加了 ARC 支持。请务必使用 1.1 beta 或 2.0 beta。

更新答案更新

简单明了:cocos2d-iphone 截至目前还不支持开箱即用的 ARC。 cocos2d-iphone 没有提供启用 ARC 的模板。

然而,v1.1 和 2.0 及更新版本都可以在启用 ARC 的项目中编译,前提是您将 cocos2d-iphone 构建到禁用 ARC 的静态库中。这就是小蒂姆游戏教程的目的。

相比之下,Kobold2D 提供的所有项目都启用了 ARC,如果您不想使用 ARC,则只需在构建设置中禁用它。我希望用户指南对您有所帮助。开始使用 Kobold2D 确实没什么需要学习的。

If you want to use cocos2d-iphone with ARC consider using Kobold2D. Every project is ARC enabled by default, you don't have to do squat just install and start coding. Since it's the default option, you can be sure that the (improved) version of cocos2d-iphone in Kobold2D is tested well with ARC and contains a few additional ARC fixes.

Cocos2D as of v1.0.1 / 1.1 beta and 2.0 beta2 both do not support ARC out of the box (no ARC-enabled template project is available). This Tiny Tim games tutorial and this Ray Wenderlich tutorial teach you how to set up cocos2d-iphone properly to build as a static library so that you can enable ARC for your project's code.

Possible reasons why you don't see ARC as an option:

  • the project isn't set to use the "Apple LLVM Compiler 3.0"
  • you were looking for ARC but the Build Setting is actually named "Objective-C Automatic Reference Counting"

Note that cocos2d-iphone 1.0.1 (current stable release) to my knowledge is not compatible with ARC, but I believe v1.1 beta has added ARC support. Be sure to use either 1.1 beta or 2.0 beta.

Update to answer Update

Straight and simple: cocos2d-iphone as of today does NOT support ARC out of the box. There is no ARC-enabled template that cocos2d-iphone provides.

However, both v1.1 and 2.0 and newer can compile in an ARC-enabled project provided that you build cocos2d-iphone into a static library which has ARC disabled. That's what the Tiny Tim games tutorial is for.

In contrast all projects provided by Kobold2D have ARC enabled, and if you don't want to use ARC you just need to disable it in Build Settings. I hope you'll find the User's Guide helpful. There really isn't much to learn to get started with Kobold2D.

怀中猫帐中妖 2025-01-04 09:50:51

我已经编写了如何使用 Kobold2D 将静态 SimpleAudio cocos2d 引擎添加到 ARC 项目的简短分步 - https:/ /coderwall.com/p/jslwrg
您也可以将它用于所有 cocos2d 库...

I've written short step-by-step how to add static SimpleAudio cocos2d engine to your ARC project with Kobold2D - https://coderwall.com/p/jslwrg
You can use it for all cocos2d library too...

三生池水覆流年 2025-01-04 09:50:51

我只是在做这个;使用 Xcode 中的编辑->重构->转换为 Obj-C ARC 工具,可以非常快速地将基本的 Cocos2D 2.0 转换为 ARC。

只需使用 Cocos2D 模板打开一个新项目,转换为 ARC,选择 4 个底部文件(.m)并保存!

I was just doing this; Using the Edit->Refactor->Convert to Obj-C ARC tool in Xcode it was very quick to convert the basic Cocos2D 2.0 to ARC.

Just open a new project with the Cocos2D template, convert to ARC, select the 4 bottom files (.m) and save!

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