As3精灵旋转X和旋转Y [英] As3 sprite rotationX and rotationY

查看:147
本文介绍了As3精灵旋转X和旋转Y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rotationX和rotationY有点问题.

I have a bit problem with rotationX and rotationY.

如果我只在下面做一个roationX和rotaionY,那就太酷了

It's cool if i just do a roationX and rotaionY below

_eventParent.rotationY =_differentX; 
_eventParent.rotationX =_differentY;

但是,一旦我将鼠标移动分配给_eventParent.当鼠标移动时,roationX和roationY会发生透视变化.因此,该商品的尺寸保持不变.它会增加和减小尺寸.知道为什么要这样做吗?有没有可能停止这种行为?

However once i have assign a mouse move to the _eventParent. The roationX and roationY change perspectively while the mouse is moving. so instead the item remain the same size. it increase and decrease size prospectively. any idea why is it doing this? is there a possibility to stop this behavior?

谢谢

请在下面找到图片.

推荐答案

透视图允许您的形状的一部分比其他部分看起来更靠近您.问题在于透视图具有中心或消失点",默认情况下,它是固定的.当您将形状移离消失点更远时,视角会发生变化,从而导致形状变大或变窄.

Perspective allows part of your shape to look closer to you than other parts. The problem is that perspective has a center, or "vanishing point" and by default, it is fixed. As you move your shape farther away from the vanishing point, the perspective changes, causing your shape to widen or narrow.

您可以通过更新消失点来解决此问题,以使其始终与您的形状处于同一坐标.由于形状将始终处于消失点,因此透视图不应更改.

You can fix this by updating the vanishing point so that it is always at the same coordinates as your shape. Since the shape will always be at the vanishing point, the perspective shouldn't change.

为此,请为您的形状创建一个PerspectiveProjection:

To do this, create a perspectiveProjection for your shape:

_eventParent.transform.perspectiveProjection = new PerspectiveProjection();

PerspectiveProjection位于flash.geom包中,因此请不要忘记导入它.

PerspectiveProjection is located in the flash.geom package, so don't forget to import it.

然后,只要您更新形状的位置,就更新它的消失点:

Then whenever you update your shape's position, update it's vanishing point:

_eventParent.transform.perspectiveProjection.projectionCenter = 
    new Point(_eventParent.x, _eventParent.y);

您可能需要将消失点偏移一定数量的像素,以使透视图看起来像您想要的那样.

You might need to offset the vanishing point by a set number of pixels to get the perspective looking the way you want it to.

这篇关于As3精灵旋转X和旋转Y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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