up:前进
down:后退
left:左转
right:右转
obj = {x:200, y:1, z:100};
//所在位置
mc = _root.mc.attachMovie("dummy", "dm", 0);
py = 0;
px = 0;
speed = 10;
d = 600;
fz = 0;
fx = 0;
fy = 0;
rx = ry=rz=0;
radio = 0;
onEnterFrame = function () {
if (Key.isDown(Key.LEFT)) {
radio -= 0.07;
} else if (Key.isDown(Key.RIGHT)) {
radio += 0.07;
}
sin = Math.sin(radio);
cos = Math.cos(radio);
if (Key.isDown(Key.UP)) {
//rx -= cos*speed;
//rz -= sin*speed;
rx -= sin*speed;//
ry=ry;
rz -= cos*speed;//深度减少
} else if (Key.isDown(Key.DOWN)) {
//rx += cos*speed;
//rz += sin*speed;
rx += sin*speed;//
ry=ry
rz += cos*speed;//深度增加
}
//trace(rx)
fx = obj.x+rx;
fy = obj.y+ry;
fz = obj.z+rz;
px = fx*cos-fz*sin;
py = fy;
pz = fx*sin+fz*cos;
rad = d/(pz);
cx = px*rad;
cy = py*rad;
if (cy>0) {
mc._x = cx;
mc._y = cy;
mc._xscale = mc._yscale=rad*100;
}
};
down:后退
left:左转
right:右转
obj = {x:200, y:1, z:100};
//所在位置
mc = _root.mc.attachMovie("dummy", "dm", 0);
py = 0;
px = 0;
speed = 10;
d = 600;
fz = 0;
fx = 0;
fy = 0;
rx = ry=rz=0;
radio = 0;
onEnterFrame = function () {
if (Key.isDown(Key.LEFT)) {
radio -= 0.07;
} else if (Key.isDown(Key.RIGHT)) {
radio += 0.07;
}
sin = Math.sin(radio);
cos = Math.cos(radio);
if (Key.isDown(Key.UP)) {
//rx -= cos*speed;
//rz -= sin*speed;
rx -= sin*speed;//
ry=ry;
rz -= cos*speed;//深度减少
} else if (Key.isDown(Key.DOWN)) {
//rx += cos*speed;
//rz += sin*speed;
rx += sin*speed;//
ry=ry
rz += cos*speed;//深度增加
}
//trace(rx)
fx = obj.x+rx;
fy = obj.y+ry;
fz = obj.z+rz;
px = fx*cos-fz*sin;
py = fy;
pz = fx*sin+fz*cos;
rad = d/(pz);
cx = px*rad;
cy = py*rad;
if (cy>0) {
mc._x = cx;
mc._y = cy;
mc._xscale = mc._yscale=rad*100;
}
};
回复Comments
作者:
{commentrecontent}