Actionscript 中是否有 Z 位置变化的偏移方程?

发布于 2024-08-07 15:22:32 字数 240 浏览 3 评论 0原文

假设我有一个影片剪辑,加载时我将其 .z 位置设置为 2000,使其在背景中看起来很远...我到底如何才能确定它的 x 和 y 点将出现在哪里在舞台上?有方程式吗?

例如;

original.x = 200;
original.y = 200;
original.z = 0;

new.z = 2000;
new.x = original.x*10;
new.y = original.y*10;

Say I have a movie clip that when loaded I set it's .z position to 2000 to make it look far off in the background... How in the world can I set it's x and y points with any certainty as to where it will appear on the stage? Is there an equation?

E.g.;

original.x = 200;
original.y = 200;
original.z = 0;

new.z = 2000;
new.x = original.x*10;
new.y = original.y*10;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我做我的改变 2024-08-14 15:22:32

您必须将实际的 x 和 y 点与 3D 空间点分开(我使用 _x、_y 和 _z)。使用一个基本想法,即任何离你更远的东西都将是,你将需要定义消失点的原点和“焦距”(想想相机镜头),这将定义物体消失在背景中的速度。尝试使用值,但 200 左右的值通常效果很好。
这应该给你一些像这样简单的东西,其中 my_mc 是你想要产生效果的对象:

my_mc._x = 0; 
my_mc._y = 0; 
my_mc._z = 200;
var scaleRatio = focalLength/(focalLength + my_mc._z);
my_mc.x = origin.x + my_mc._x * scaleRatio;
my_mc.y = origin.y + my_mc._y * scaleRatio;
my_mc.scaleX = my_mc.scaleY = scaleRatio;

在 kirupa 有一些关于这个主题的非常好的教程,尝试这个(虽然它是在 as2 中,但理论是相同的)
http://www.kirupa.com/developer/actionscript/3dexplore.htm

you have to seperate out the actual x and y points with the 3D space points (i use _x, _y and _z). using a basic idea that anything further away from you is going to be you will need to define an origin for the vanishing point and a "focal length" (think of a camera lens) that will define how quickly things dissappear into the background. try playing with values, but something around 200 usually works fairly well.
this should give you something simple like this where my_mc is the object you want to have the effect on:

my_mc._x = 0; 
my_mc._y = 0; 
my_mc._z = 200;
var scaleRatio = focalLength/(focalLength + my_mc._z);
my_mc.x = origin.x + my_mc._x * scaleRatio;
my_mc.y = origin.y + my_mc._y * scaleRatio;
my_mc.scaleX = my_mc.scaleY = scaleRatio;

there are some really good tutorials at kirupa on this subject, try this one (though it is in as2 the theory is the same)
http://www.kirupa.com/developer/actionscript/3dexplore.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文