creen un cuadrito movie clip y pongan esto
Código ActionScript :
onClipEvent (load) {
speed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
}
// atras
if (Key.isDown(Key.DOWN)) {
speed -= 1;
if (Math.abs(speed)>20) {
speed *= .7;
}
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
speed *= .9;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
//aqui un movieclip llamado land son los bordes para que no se salga.
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
daños += 1;
} else {
car, play();
speed *= -1;
}
}
///luego esto en un clip llamado car para perseguirlo
Código ActionScript :
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._car._y-this._y, _root.car._x-this._x);
// Calculates the mouse angle in radians
myDegrees = Math.round((myRadians*180/Math.PI));
// Converts the mouse angle to degrees so it can be expressed in _rotation terms
_root.yChange = Math.round(_root.car._y-this._y);
// Calculates the distance between the movie clip and the mouse
_root.xChange = Math.round(_root.car._x-this._x);
// Calculates the distance between the movie clip and the mouse
_root.yMove = Math.round(_root.yChange/60);
// Determines the amount the movie clip should move toward the mouse, grows larger the further the mouse gets from the MC
// si quereis camviar este 60 de acontinuacion dara mas o o menos la velocidad que querais que te persiga.
_root.xMove = Math.round(_root.xChange/60);
// See above
this._y += _root.yMove;
//Adds yMove onto the position of the clip (Note: Must be '+=' and not '-=' or else the MC will move away from the mouse, not towards it
this._x += _root.xMove;
// See above
this._rotation = myDegrees+90;
// Turns the MC to face the mouse
} 