使用精灵开发 iPhone
我想制作一款 iPhone/iPod 游戏。 我希望它是 3d 的,但我想使用精灵而不是 OpenGL 来做到这一点(我认为这会更容易,因为我不知道 OpenGL)。
我正在考虑简单地将精灵叠加在一起并改变它们的大小以产生 3D 的错觉。 它不需要太有说服力,因为游戏会有点卡通化。
如何在 iPhone 平台上使用精灵来替代 OpenGL?
I want to create an iPhone/iPod game. I want it to be 3d, but I want to use sprites instead of OpenGL to do this (I assume this would be easier since I don't know OpenGL).
I was thinking of simply layering sprites over top of each other and changing their size to give an illusion of 3d. It doesn't need to be too convincing since the game will be somewhat cartoony.
How can I use sprites as an alternative to OpenGL on the iPhone platform?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 CoreAnimation 来实现此目的。 使用
UIImageViews
(或普通UIViews
)或CALayers
。它通常是某些类型的 2D 游戏(例如棋盘游戏)的最佳选择,因为动画、旋转和缩放非常简单。 请记住,如果您关心性能,OpenGL 总是更好。
You can use CoreAnimation for this. Either using
UIImageViews
(or plainUIViews
) orCALayers
.It's usually the best choice for some types of 2d games (board games, for example), since animation, rotation and scaling are really easy. Just keep in mind that if performance is your concern, OpenGL will always be better.
根据 3d 的程度,我建议看看 cocos2d。 它支持多个图层、精灵、动画等,但使用起来非常简单。 学习。 (对我来说比OpenGL容易得多)示例代码非常全面。
http://code.google.com/p/cocos2d-iphone/
Depending on how much 3d, I'd recommend taking a look at cocos2d. It supports multiple layers, sprites, animations, etc, but is pretty straightforward to pick up & learn. (Much easier than OpenGL to me) The example code is very comprehensive.
http://code.google.com/p/cocos2d-iphone/
我使用核心动画构建了一个游戏,其中最多有 17 - 20 个物体在屏幕上浮动缩放和旋转,并且在 iPhone 上性能良好(请确保定期在 iPhone 上检查,因为模拟器不模拟 iPhone 内存或 CPU 速度)。
CoreAnimation 非常简单而且非常强大。 使用 PNG 图像,我认为您不会遇到很多问题。 真正的杀手是图像中的阿尔法,这对于 iPhone 来说是一项艰苦的工作。 因此,透明度越低,您的应用程序运行得越好。
I have built a game using core animation with upto about 17 - 20 objects floating about the screen scaling and rotating and performance was fine on the iPhone (make sure you check regularly on the iPhone as the simulator doesnt simulate iPhone memory or CPU speed).
CoreAnimation is pretty simple and really powerful. Use PNG's for images and I don't think you will have to many issues. The real killer of this will be alpha's in your images, this is hard work for the iPhone. So the less transparency you have the better you app will go.
除了 Marco 的回答之外,我想补充一点:不使用 OpenGL 可能还会对设备电池造成更多负担。 据我了解,OpenGL ES 在设备电源上可以更加高效(如果实施得当)。 当然,这取决于
UIImageView
、UIView
或CALayers
等将使用多少动画。我确信有一个转折点。
In addition to Marco's answer I want to add: Not using OpenGL may also tax the device battery a little more. As I understand it, OpenGL ES can be more efficient on a device power supply (if implemented properly). Of course, this depends on how much animation is going to be used with
UIImageView
,UIView
orCALayers
, etc.I'm sure there is a tipping point.