简体   繁体   English

使用精灵进行iPhone开发

[英]iPhone development using sprites

I want to create an iPhone/iPod game. 我想创建一个iPhone / iPod游戏。 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). 我希望它是3d,但我想使用精灵而不是OpenGL来做到这一点(我认为这会更容易,因为我不知道OpenGL)。

I was thinking of simply layering sprites over top of each other and changing their size to give an illusion of 3d. 我想的是简单地将精灵叠加在彼此之上并改变它们的大小以给出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? 如何在iPhone平台上使用精灵作为OpenGL的替代品?

You can use CoreAnimation for this. 您可以使用CoreAnimation。 Either using UIImageViews (or plain UIViews ) or CALayers . 或者使用UIImageViews (或纯UIViews )或CALayers

It's usually the best choice for some types of 2d games (board games, for example), since animation, rotation and scaling are really easy. 它通常是某些类型的2D游戏(例如棋盘游戏)的最佳选择,因为动画,旋转和缩放非常简单。 Just keep in mind that if performance is your concern, OpenGL will always be better. 请记住,如果您关注性能,OpenGL将永远更好。

Depending on how much 3d, I'd recommend taking a look at cocos2d. 根据3d的数量,我建议看看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. (对我来说比OpenGL容易得多)示例代码非常全面。

http://code.google.com/p/cocos2d-iphone/ http://code.google.com/p/cocos2d-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). 我已经使用核心动画构建了一个游戏,其中大约有17到20个对象漂浮在屏幕上,缩放和旋转,并且iPhone上的性能很好(确保定期检查iPhone,因为模拟器不会模拟iPhone内存或CPU速度)。

CoreAnimation is pretty simple and really powerful. CoreAnimation非常简单,非常强大。 Use PNG's for images and I don't think you will have to many issues. 使用PNG的图像,我认为你不会有很多问题。 The real killer of this will be alpha's in your images, this is hard work for the iPhone. 真正的杀手将是你的图像中的alpha,这对iPhone来说很难。 So the less transparency you have the better you app will go. 因此,您拥有的透明度越低,您的应用就越好。

In addition to Marco's answer I want to add: Not using OpenGL may also tax the device battery a little more. 除了Marco的答案之外,我想补充一点:不使用OpenGL也可能会对设备电池征税。 As I understand it, OpenGL ES can be more efficient on a device power supply (if implemented properly). 据我了解,OpenGL ES可以在设备电源上更高效(如果正确实施)。 Of course, this depends on how much animation is going to be used with UIImageView , UIView or CALayers , etc. 当然,这取决于UIImageViewUIViewCALayers等将使用多少动画。

I'm sure there is a tipping point. 我确信有一个引爆点。

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

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