求牛人转代码,一个汽车游戏 但是是AS 2.0编纂的,怎样转换成AS 3.0
求牛人转代码,一个汽车游戏 但是是AS 2.0编写的,怎样转换成AS 3.0
这是那个游戏的网址
http://www.emanueleferonato.com/2007/05/15/create-a-flash-racing-game-tutorial/
car1.code = "player";
//this variable will decide if the specified car is controlled by a human player or by the computer (in Part II of this tutorial you will learn how to add opponents and this variable will come in handy)
acceleration = 0.4;
//the acceleration variable will add to the speed variable on every enterFrame event (in this case 24 times per second); a higher value translates in a faster acceleration of the car
speedDecay = 0.96;
//when the car is not accelerated (the UP Key is released), the car will have to slow down smoothly; the speed will multiply with this value (less than 1); the lower this value is, the faster the car will slow down
rotationStep = 10;
//this is the number of degrees that will increase or decrease the car's rotation (angle) when the left or right keys are pressed
maxSpeed = 10;
//this is the speed limit on our track; increase it if you want the car to go faster
backSpeed = 1;
//this is the speed limit when going backwards
function step(who) {
//check to see if the car in question is controlled by the player or by the computer
if (_root["car"+who].code == "player") {
//we will constantly decrease speed by multiplying it with a number below 1, but only if speed if higher than 0.3; a lower value will only consume resources and movement will not even be noticed so we will set the speed variable to 0
if (this["speed"+who]>0.3) {
this["speed"+who] *= _root.speedDecay;
} else {
this["speed"+who] = 0;
}
//the car will react to certain key presses that we will capture using the Key.isDown method as follows
//accelerate - we add a certain value to the speed variable if the UP key is pressed and the speed is lower than it's maximum alowed value
if (Key.isDown(Key.UP) && this["speed"+who]<_root.maxSpeed) {
this["speed"+who] += _root.acceleration;
}
//brake (reverse) - same thing, but here we subtract
if (Key.isDown(Key.DOWN)) {
this["speed"+who] -= _root.backSpeed;
}
//steer left - well, we could simply add or subtract a fixed angle (in degrees) to/from the car's rotation, but that's not good enough. In order to simulate a natural movement, steering must depend on speed, otherwise you will be able to rotate your car even if it's almost stopped and it will look like a propeller :)
这是那个游戏的网址
http://www.emanueleferonato.com/2007/05/15/create-a-flash-racing-game-tutorial/
car1.code = "player";
//this variable will decide if the specified car is controlled by a human player or by the computer (in Part II of this tutorial you will learn how to add opponents and this variable will come in handy)
acceleration = 0.4;
//the acceleration variable will add to the speed variable on every enterFrame event (in this case 24 times per second); a higher value translates in a faster acceleration of the car
speedDecay = 0.96;
//when the car is not accelerated (the UP Key is released), the car will have to slow down smoothly; the speed will multiply with this value (less than 1); the lower this value is, the faster the car will slow down
rotationStep = 10;
//this is the number of degrees that will increase or decrease the car's rotation (angle) when the left or right keys are pressed
maxSpeed = 10;
//this is the speed limit on our track; increase it if you want the car to go faster
backSpeed = 1;
//this is the speed limit when going backwards
function step(who) {
//check to see if the car in question is controlled by the player or by the computer
if (_root["car"+who].code == "player") {
//we will constantly decrease speed by multiplying it with a number below 1, but only if speed if higher than 0.3; a lower value will only consume resources and movement will not even be noticed so we will set the speed variable to 0
if (this["speed"+who]>0.3) {
this["speed"+who] *= _root.speedDecay;
} else {
this["speed"+who] = 0;
}
//the car will react to certain key presses that we will capture using the Key.isDown method as follows
//accelerate - we add a certain value to the speed variable if the UP key is pressed and the speed is lower than it's maximum alowed value
if (Key.isDown(Key.UP) && this["speed"+who]<_root.maxSpeed) {
this["speed"+who] += _root.acceleration;
}
//brake (reverse) - same thing, but here we subtract
if (Key.isDown(Key.DOWN)) {
this["speed"+who] -= _root.backSpeed;
}
//steer left - well, we could simply add or subtract a fixed angle (in degrees) to/from the car's rotation, but that's not good enough. In order to simulate a natural movement, steering must depend on speed, otherwise you will be able to rotate your car even if it's almost stopped and it will look like a propeller :)