在 iOS 上使用 Core Animation 与使用 Cocos2D 和 OpenGL ES 的适用性? [英] Suitability of using Core Animation on iOS vs using Cocos2D and OpenGL ES?

查看:31
本文介绍了在 iOS 上使用 Core Animation 与使用 Cocos2D 和 OpenGL ES 的适用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一本书中完成了突围游戏教程,但是球,这是一个 20x20 像素的图像,正在跳帧并且移动不是很流畅.模拟器和 iPhone 4S(真机)就是这种情况.该代码没有使用 NSTimer(可能会更慢),而是使用 CADisplayLinkUIImageView setFrame 来制作动画.

I finished a breakout game tutorial in a book, but the ball, which is a 20x20 pixel image, was skipping frames and not moving very smoothly. That is the case on the Simulator as well as on an iPhone 4S (the real thing). The code wasn't using NSTimer (which may be slower), but was using CADisplayLink and UIImageView setFrame to do the animation.

iOS 上的 Core Animation 不是很适合开发动画类型的游戏吗?说是不是游戏

Is Core Animation on iOS not very suitable for development animation type of games? Say if it is a game of

  1. 入侵者(太空入侵者)
  2. Breakout(作为教程中的游戏)
  3. 打砖块
  4. 愤怒的小鸟/割绳子/水果忍者

对于这些类型的游戏,Core Animation真的适合写上面(2)吗?对于 (1)、(3) 和 (4),无论是 Cocos2D 还是 OpenGL ES 都更适合做这项工作.并且 Cocos2D 和 OpenGL ES 的性能非常接近.这是真的吗?

For these types of games, is Core Animation really suitable for writing (2) above? For (1), (3), and (4), either Cocos2D or OpenGL ES is more suitable of doing the job. And the performance of Cocos2D and OpenGL ES are very close. Is that true?

推荐答案

Cocos2D 经常被关注,因为它易于编写常见的游戏逻辑,如碰撞检测和精灵动画、逐帧、缩放和其他处理在游戏开发中很常见,您可以将多个动画串在一起,然后组合,对它们进行排序,进行回调等等.这是引擎的一大优势.

Cocos2D is often looked at because of its ease for programming common game logic, like collision detection and sprite animations, frame-by-frame, scaling and other processes that are quite common in game development, where you string together multiple animations, combine then, sequence them, do call backs, and more. That is one of the big benefits of the engine.

但是,性能是另一回事.Cocos 提供批处理节点,将所有图形元素组合到一个 OpenGL 调用中,而不是在每一帧中分别绘制"到屏幕上;这可以显着提高性能,尤其是对于大型图形.如果你有跳帧,我想知道 Cocos 中的批处理精灵是否会是缺失的链接.

However, performance is another. Cocos offers batch nodes, which combine all graphic elements into a single OpenGL call, rather than "drawing" each to the screen separately in each frame; this can dramatically improve performance, especially for large graphics. If you had skipping frames, I wonder if batch sprites in Cocos would have been the missing link.

Core Animation 给我留下了深刻的印象,并希望它能够在游戏中出现性能问题.我的理解是 CA 和 Cocos 一样,也是建立在 OpenGL ES 之上的,所以我希望两者都能取得好的结果.可能在 Cocos 中这样做更容易,因为它在内部针对游戏开发进行了设计和优化.

I'm very impressed by Core Animation and want to hope that it can hold its own with performance issues in games. My understanding is that CA is, like Cocos, also built on top of OpenGL ES, so I'd expect it possible to achieve good results in either. It could be that doing so in Cocos is easier simply because it has been designed and optimized internally for game development.

这篇关于在 iOS 上使用 Core Animation 与使用 Cocos2D 和 OpenGL ES 的适用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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