我正在尝试将以下 AS2 代码转换为 AS3,因为我有 Adobe Flash CC,据我所知(根据研究、试验和错误),它不支持 AS2 代码。任何帮助将不胜感激...
onClipEvent(load) {
speed = 0;
acceleration = 0.4;
speedDecay = 0.96;
maxSpeed = 10;
backSpeed = 1;
}
onClipEvent(enterFrame) {
if(Math.abs(speed) > 0.3) {
speed *= speedDecay;
}else {
speed = 0;
}
if(Key.isDown(Key.UP)) {
if (Math.abs(speed) >= maxspeed) {
speed += acceleration;
}
}
if(Key.isDown(Key.DOWN)) {
if(speed < 0.5)
speed = -2;
else
speed--;
}
if (Math.abs(speed)> 0.5) {
if (Key.isDown(Key.LEFT)) {
_rotation -= 10;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 10;
}
}
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.ground.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
}else {
speed -= speed*1.5;
}
}
此代码位于我的汽车游戏的汽车层中。