简体   繁体   English

为什么在2D iPhone游戏中使用Cocos而不是UI Kit?

[英]Why use Cocos over UI Kit for a 2D iPhone game?

I have been building a game in cocos for a while now I it has just occurred to me that it might just be a whole lot easier to use UIKit. 我已经在科科斯建立了一段时间的游戏现在我刚刚发现,使用UIKit可能要容易得多。

Could you please help me weight up the pros and cons, and share some experiences you have. 能否帮助我减轻利弊,分享一些经验。

Here is my basic list of advantages for each. 这是我的每个优点的基本列表。 I feel I dont know enought about cocos to make a informed decision which is best. 我觉得我不知道科克斯应该做出最明智的决定。

Cocos 科科斯

  • Game engine comes for free. 游戏引擎免费提供。 Pause / resume callbacks every frame 每帧暂停/恢复回调
  • Sprite animations 精灵动画
  • Uses open GL (is this true? is this an advantage?) 使用开放GL(这是真的吗?这是一个优势吗?)
  • ...Help me think of some more! ......帮我想一想!

UI Kit UI套件

  • Far more Help / Documentation / Sample Code 更多帮助/文档/示例代码
  • Familiar for iPhone programmers 熟悉iPhone程序员
  • Easy to handel touch 容易handel触摸
  • Easy view animations 轻松查看动画
  • Easy to customise 易于定制
  • Faster loading times? 加载时间更快? (is this true?) (这是真的?)

Any feedback would be great! 任何反馈都会很棒!

EDIT : I have just seen a developer video (on an open GL game called Quest) where they used UI Kit for the UI elements, drawn over the top of the GL View. 编辑 :我刚刚看到一个开发者视频(在一个名为Quest的开放式GL游戏中),他们在UI视图的顶部绘制了用于UI元素的UI工具包。 Is this possible / practical with cocos? 这可能/实用cocos?

  1. Cocos2d uses OpenGL for drawing its sprites, movements, and particles. Cocos2d使用OpenGL绘制其精灵,运动和粒子。 Trying to use Quartz/Core Graphics (which is NOT accelerated!) is fundamentally much slower and power hungry. 尝试使用Quartz / Core Graphics(不加速!)从根本上说要慢得多,而且耗电量大。
  2. Cocos2d is a sprite library with a scenegraph first and foremost. Cocos2d是一个精灵库,首先是场景图。 You would be duplicating effort to make a scenegraph using UIKit. 您将重复使用UIKit制作场景图的努力。
  3. There are lots of nice freebies that work within Cocos which you would have to develop from the ground up. 在Cocos中有许多不错的免费赠品,你必须从头开始发展。

So, in short: It draws way faster than CPU bound drawing calls, it provides 95% of what most sprite based games need without reinventing the same thing over and over, and is free. 因此,简而言之:它比CPU绑定绘图调用绘制速度更快,它提供了大多数基于精灵的游戏所需的95%,而无需反复重复同样的事情,并且是免费的。

Although UIKit is incredibly useful for gaming, Cocos2D offers a variety of easier ways to accomplish many common game-making operations. 虽然UIKit对游戏非常有用,但Cocos2D提供了各种更简单的方法来完成许多常见的游戏制作操作。 For instance, it has the ability to create easy scrolling-tile games (very common and very popular) using a simple few lines of code to import a "Tiled" map set. 例如,它能够使用简单的几行代码创建简单的滚动平铺游戏(非常常见非常流行)来导入“平铺”地图集。 In terms of some of the benefits of UIKit over Cocos2D that you mentioned, they are very easy to accomplish in Cocos2D, as well. 就你所提到的UIKit相对于Cocos2D的一些好处而言,它们在Cocos2D中也容易实现。

Touch handling: This is as easy as replacing the "touchesBegan" method of UIKit with "ccTouchesBegan" and setting self.isTouchEnabled = YES in the init method. 触摸处理:这就像用“ccTouchesBegan”替换UIKit的“touchesBegan”方法并在init方法中设置self.isTouchEnabled = YES

Animations: This is so much easier in Cocos2d, mainly because frame rate and animation issues are solved. 动画:这在Cocos2d中要容易得多,主要是因为帧速率和动画问题得到了解决。 In UIKit, you cannot use CoreAnimation to move an object while still implementing collision detection. 在UIKit中,您无法使用CoreAnimation移动对象,同时仍实现碰撞检测。 You would have to animate the object with an NSTimer. 您必须使用NSTimer为对象设置动画。 In Cocos2d, you can easily animate objects (called sprites) and still use collision detection and interaction with the object. 在Cocos2d中,您可以轻松地为对象(称为精灵)设置动画,并仍然使用碰撞检测和与对象的交互。

More Help/Documentation: Cocos2D offers an incredible amount of documentation and, even more so, examples of code! 更多帮助/文档: Cocos2D提供了大量的文档,甚至更多的代码示例! If you can't find it there, there is a growing number of iPhone game developers who implement Cocos2D in their apps and are willing to help many problems. 如果你在那里找不到它,那么越来越多的iPhone游戏开发者在他们的应用程序中实现Cocos2D并愿意帮助解决许多问题。

If you are planning on developing games for iPhone, and not just general apps for productivity, music, etc., I highly suggest Cocos2D. 如果你打算为iPhone开发游戏,而不仅仅是生产力,音乐等的一般应用程序,我强烈建议使用Cocos2D。 Remember, you can always still find ways to combine this and UIKit for many operations! 请记住,您仍然可以找到将此功能与UIKit结合使用的方法! Those operations aren't completely lost! 那些操作并没有完全丢失!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM