Foros del Web » Creando para Internet » Flash y Actionscript »

aceleración a objeto que sigue puntero de mouse

Estas en el tema de aceleración a objeto que sigue puntero de mouse en el foro de Flash y Actionscript en Foros del Web. Buenas, tengo el código acerca de un objeto que sigue la posición del puntero del mouse. El asunto es que necesitaría agregarle a este código ...
  #1 (permalink)  
Antiguo 30/10/2009, 23:46
 
Fecha de Ingreso: octubre-2009
Mensajes: 2
Antigüedad: 14 años, 5 meses
Puntos: 0
aceleración a objeto que sigue puntero de mouse

Buenas, tengo el código acerca de un objeto que sigue la posición del puntero del mouse. El asunto es que necesitaría agregarle a este código la posibilidad de que el objeto acelere el desplazamiento, evitando así que su trayectoria sea siempre uniforme.

Podría alguien darme una mano?

Gracias de antemano.

aquí el código:

Código :

Código:
var Speed:Number = 0.3 // Velocidad del personaje
var TmpXY:Number = 0;

onEnterFrame = function() {
   gotoSpotX = this._parent._xmouse;
   gotoSpotY = this._parent._ymouse;


   
   // calculate angle of current position to target position 
   delta_x = this._x-gotoSpotX;
   delta_y = this._y-gotoSpotY;
   targetRotation = -Math.atan2(delta_x, delta_y)/(Math.PI/180);
   if (targetRotation<0){
      targetRotation += 360//Acomoda el angulo para que sea de 360 grados
   }   
   
   // move beetle toward the target and stop when it gets there
   if (Math.sqrt((delta_x*delta_x)+(delta_y*delta_y))>Speed) {
      _y -= Speed*Math.cos(targetRotation*(Math.PI/180));
      _x += Speed*Math.sin(targetRotation*(Math.PI/180));
      this.Fachadas.Parado = false; //Controla fachada de estar parado
   }else{
      this.Fachadas.Parado = true;
   }
   
   // 
   // loop to opposite side of the masked area when the beetle travels off-screen
   if (_y<0) {
      _y=0;
   }
   if (_y>1024) {
      _y=1024;
   }
   if (_x<0) {
      _x=0;
   }
   if (_x>800) {
      _x = 800;
   }
   
    
   
   // Asigna el cambio de fachadas
   if (targetRotation<20){
      this.Fachadas.Angulo = 0;
   }else if (targetRotation<70){
      this.Fachadas.Angulo = 45;
   }else if (targetRotation<100){
      this.Fachadas.Angulo = 90;
   }else if (targetRotation<150){
      this.Fachadas.Angulo = 135;
   }else if (targetRotation<183){
      this.Fachadas.Angulo = 180;
   }else if (targetRotation<240){
      this.Fachadas.Angulo = 225;
   }else if (targetRotation<290){
      this.Fachadas.Angulo = 270;
   }else if (targetRotation<335){
      this.Fachadas.Angulo = 315;
   }else if (targetRotation<360){
      this.Fachadas.Angulo = 0;
   
   }
   

   
   this.Direccion._rotation = targetRotation; // Borrar esto
   XY =  int(_x) + " ; " + int(_y); // Borrar esto
   Ang =  this.Fachadas.Angulo; // Borrar esto
}
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:59.