El código que se introduce en el video para el segundo coche es:
onClipEvent(load) {
speed = 0;
acceleration = 0.4;
speedDecay = 0.96;
maxSpeed = 10;
backSpeed = 1;
lap2 = 1;
totallaps2 = 3;
var fulllap2:Boolean = false;
}
onClipEvent(enterFrame) {
if(Math.abs(speed) > 0.3) {
speed *= speedDecay;
}else {
speed = 0;
}
if(Key.isDown(87)) {
if (Math.abs(speed) >= maxspeed) {
speed += acceleration;
}
}
if(Key.isDown(83)) {
if(speed < 0.5) speed = -2; else speed--; } if (Math.abs(speed)> 0.5) {
if (Key.isDown(65)) {
_rotation -= 10;
}
if (Key.isDown(68)) {
_rotation += 10;
}
}
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.bordes.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
}else {
speed -= speed*1.5;
}
}
onClipEvent(enterFrame) {
if (_root.checkpoint1.hitTest(this)) {
if(fulllap2){
if(lap2 >= totallaps2)
_root.gotoAndStop(3);
++lap2;
fulllap2 = false;
}
}
if (_root.checkpoint2.hitTest(this)) {
fulllap2 = true;
}
_root.currentlap2 = lap2 + "/" + totallaps2;
_root.puntos2 = puntos2;
seconds = Math.floor(getTimer()/1000);
minutes = Math.floor(seconds/60);
tens = Math.round((getTimer()-seconds*1000)/10);
if(minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
if (tens < 10 ) {
tens = "0" + tens;
}
_root.totaltime2 = minutes + "." + seconds + "." + tens;
}
speed = 0;
acceleration = 0.4;
speedDecay = 0.96;
maxSpeed = 10;
backSpeed = 1;
lap2 = 1;
totallaps2 = 3;
var fulllap2:Boolean = false;
}
onClipEvent(enterFrame) {
if(Math.abs(speed) > 0.3) {
speed *= speedDecay;
}else {
speed = 0;
}
if(Key.isDown(87)) {
if (Math.abs(speed) >= maxspeed) {
speed += acceleration;
}
}
if(Key.isDown(83)) {
if(speed < 0.5) speed = -2; else speed--; } if (Math.abs(speed)> 0.5) {
if (Key.isDown(65)) {
_rotation -= 10;
}
if (Key.isDown(68)) {
_rotation += 10;
}
}
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.bordes.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
}else {
speed -= speed*1.5;
}
}
onClipEvent(enterFrame) {
if (_root.checkpoint1.hitTest(this)) {
if(fulllap2){
if(lap2 >= totallaps2)
_root.gotoAndStop(3);
++lap2;
fulllap2 = false;
}
}
if (_root.checkpoint2.hitTest(this)) {
fulllap2 = true;
}
_root.currentlap2 = lap2 + "/" + totallaps2;
_root.puntos2 = puntos2;
seconds = Math.floor(getTimer()/1000);
minutes = Math.floor(seconds/60);
tens = Math.round((getTimer()-seconds*1000)/10);
if(minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
if (tens < 10 ) {
tens = "0" + tens;
}
_root.totaltime2 = minutes + "." + seconds + "." + tens;
}
introduzco el código pero no funciona el carro solo se desliza
ResponderEliminar