Tengo el siguiente código de comandos para el movimiento del personaje pero no conozco cómo poder realizar lo antedicho.
Gracias de antemano.
Código :
var Speed:Number = 1 // 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<10) { _root.gotoAndStop(2) } if (_y>370) { _root.gotoAndStop(2) } if (_x<10) { _root.gotoAndStop(1) } if (_x>370) { _root.gotoAndStop(1) } // 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 }