本文介绍了石英2d / openGl / cocos2d图像失真在iphone通过移动顶点2.5d iphone游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正试图在iphone游戏中实现以下功能:

We are trying to achieve the following in an iphone game:

使用2d png文件,设置一个看起来像3d的场景。当用户移动设备时,各个png文件会相应地扭曲/扭曲,以产生深度效果。

Using 2d png files, set-up a scene that seems 3d. As the user moves the device, the individual png files would warp/distort accordingly to give the effect of depth.

场景示例:空房间,5个墙壁和一个椅子在中间。 = 6个png文件分层。

example of a scene: an empty room, 5 walls and a chair in the middle. = 6 png files layered.

我们使用原生函数(例如偏移和缩放)成功完成了这项工作。通过对各种墙壁和椅子应用变换,当装置倾斜移动时,墙壁将倾斜/缩放/平移。然而,问题是因为我们使用6 png文件,边缘不满足,因为我们移动设备。我们需要一个使用真实引擎的新解决方案。

We have successfully accomplished this using native functions like skew and scale. By applying transformations to the various walls and the chair, as the device is tilted moved, the walls would skew/scale/translate . However, the problem is since we are using 6 png files, the edges dont meet as we move the device. We need a new solution using a real engine.

问题:

/尺度变换,如果给定移动矩形图像的顶点的自由度,我们可以精确地扭曲图像并保持所有边缘100%对齐。

we are thinking of instead of applying skew/scale transformations, that if given the freedom to move the vertices of the rectangular images, we could precisly distort images and keep all the edges 100% aligned.

在最短的时间内,最好的框架是什么?

What is the best framework to do this in the LEAST amount of time? Are we going about this the correct way?

推荐答案

你应该能够实现这个效果使用核心动画层和适当的3-D变换。

You should be able to achieve this effect (at least in regards to the perspective being applied to the walls) using Core Animation layers and appropriate 3-D transforms.

这样的场景的一个很好的例子可以在例子中找到John Blackburn提供的。他展示了如何通过应用适当的旋转和平移来设置图层来代表迷宫中的墙壁,然后通过改变 m34 组件CATransform3D的场景。

A good example of constructing a scene like this can be found in the example John Blackburn provides here. He shows how to set up layers to represent the walls in a maze by applying the appropriate rotation and translation to them, then gives the scene perspective by using the trick of altering the m34 component of the CATransform3D for the scene.

我不知道你的椅子看起来如何使用这样的东西,但肯定你可以让你的墙壁有一个不错的视角。使用图层和Core动画可以让您使用远远少于使用OpenGL ES实现这些代码的代码。

I'm not sure how well your flat chair would look using something like this, but certainly you can get your walls to have a nice perspective to them. Using layers and Core Animation would let you pull off what you want using far less code than implementing this using OpenGL ES.

更改摄像机角度与旋转场景一样简单以响应设备方向的变化。

Altering the camera angle is as simple as rotating the scene in response to shifts in the orientation of the device.

这篇关于石英2d / openGl / cocos2d图像失真在iphone通过移动顶点2.5d iphone游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:37