method FlyTo(var _x, var _y)
{
var way;
var step;
var l = 8;
var k =
(Math.
Abs(way.
x)+0.00001)/
(Math.
Abs(way.
y)+0.00001);
if (k>1)
{
step.x = sign(way.x)*l;
step.y = sign(way.y)*l/k;
}
else
{
step.y = sign(way.y)*l;
step.x = sign(way.x)*l*k;
}
this.EndX = _x;
this.EndY = _y;
this.StepX = step.x;
this.StepY = step.y;
this.WayX = way.x;
this.WayY = way.y;
if (k>=0.5)
{
//playing animation of moving in horizontal axis
}
else
{
//playing animation of moving in vertical axis
}
var dest = Math.
Sqrt((_x -
this.
X)*
(_x -
this.
X)+
(_y -
this.
Y)*
(_y -
this.
Y));
while (dest>l)
{
this.
X =
this.
X + step.
x;
this.
Y =
this.
Y + step.
y;
dest = Math.
Sqrt((_x -
this.
X)*
(_x -
this.
X)+
(_y -
this.
Y)*
(_y -
this.
Y));
}
this.
PlayAnimAsync("idle.sprite");
// Plays some idle animation after the moving }