iOS 中的动画和旋转图像
我有一组 36 张汽车图像,需要进行交互。即,使用touchesMoved、touchesEnded 方法。点击汽车的任何部分都会显示一个弹出窗口,具体取决于水龙头下方的部分。
例如,
用户向左滑动,汽车向左旋转。然后他选择前门或其他一些部分,根据所选的部分,我可以呈现一个带有选项的弹出窗口。
我在 iOS 应用程序开发方面经验丰富,但不太熟悉动画和交互等。
我很困惑是使用 CoreGraphics 还是 openGL。有人能给我指出正确的方向吗?非常感谢一些示例代码或任何材料的链接。
I have a set of 36 car images which I need to be interactive. i.e., using the touchesMoved, touchesEnded methods. Tapping any part of the car should display a popover depending on which part is below the tap.
For example,
The user swipes left and the car rotates left. He then selects the front door or some other part and depending on the part selected, I can present a popover with options.
I am experienced in iOS app development but not well versed in animations and interactions such as these.
I am confused whether to use CoreGraphics or openGL.Can someone point me in the right direction? Some sample code or link to any material is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想绘制精灵(平面图像),那么采用第三个选项: 核心动画。在 UIView 中表示每辆汽车,并使用视图的 CALayer 实际显示汽车并使其可动画化。
如果您想将汽车绘制为三维对象,那么没有两种方法可以解决它:您必须使用 OpenGL ES。
至少在 GL 套件到达之前是这样。您仍将使用 OpenGL ES,但这应该会让事情变得更容易。问题是,您必须需要 iOS 5。
If you mean to draw sprites (flat images), then take a third option: Core Animation. Represent each car in a UIView, and use the view's CALayer to actually display the car and make it animatable.
If you want to draw the car as a three-dimensional object, then there are no two ways around it: You must use OpenGL ES.
At least until GL Kit arrives. You'll still be using OpenGL ES, but that should make it easier. The catch is, you'll have to require iOS 5.
OpenGL 要求你自己做所有事情。它为您提供了强大的绘图工具,但您必须掌握它们才能发挥作用。但最终 OpenGL 归结为铅笔、画笔和遮罩。没有像动画系统、图形对象等那样的支持。
这些必须由更高层来实现。要么是你自己写的,要么是第三方写的。 CoreGraphics本质上就是这样一个层。您的任务听起来很像基于用户滑动和对点击的反应来混合多个图像。
这可以使用 OpenGL 来完成(哎呀,与我首先必须学习 CoreGraphics 的使用相比,在 OpenGL 中进行编码可能会更快),但如果您是 OpenGL 新手,那么 CoreGraphics 可能是更好的选择。
OpenGL requires you to do everything yourself. It gives you powerfull drawing tools, but you must master them for them to be usefull. But in the end OpenGL boils down being pencils, brushes and masks. There's no kind of support like an animation system, graphics objects and so on.
Those must be implemented by a higher layer. Either written by yourself, or by third party. CoreGraphics essentially is such a layer. You task sound a lot like blending between a number of images based on user swipe and reacting to taps.
This can be done using OpenGL (heck I probably would be quicker coding that in OpenGL, than if I first had to learn the use of CoreGraphics), but if you're an OpenGL novice then CoreGraphics may be the better choice.