人物移动
/**
* 取得行走方向,水平向右为0,顺时针旋转
* (注意:在tile的宽=2*高时,右下 左下 左上 右上并非是45度)
* 0 -- 右 0度
* 1 -- 右下 45度
* 2 -- 下 90度
* 3 -- 左下 135度
* 4 -- 左 180度
* 5 -- 左上 -135度
* 6 -- 上 -90度
* 7 -- 右上 -45度
*/
public function startMove():void
{
if(!isWalk)return;
if(isNotMove)
{
if (!startNextPoint)
{
endPoint=TransforPixel.getPixelPoint(new Point(walkArray[step].x, walkArray[step].y));
dialog=Math.atan2(endPoint.y - this.y, endPoint.x - this.x);
startNextPoint=true;
degrees=dialog * 180 / Math.PI;
dir=Math.round(degrees / 45);
if (degrees < 0)
{
this.dir=Math.abs(this.dir + 8);
(dir >= 8? dir = 0 : dir);
}
dirHandler();
}
var dx:Number=endPoint.x - this.x;
var dy:Number=endPoint.y - this.y;
var distance:Number=Math.sqrt(dx * dx + dy * dy);
var radians:Number=Math.atan2(dy, dx);
xSpeed=speed * Math.cos(radians);
ySpeed=speed * Math.sin(radians);
this.x+=xSpeed;
this.y+=ySpeed;
flag++;
if (flag == 5)
{
ySort();
flag=0;
}
if (distance < 3.4)
{
_nowX=walkArray[step].x;
_nowY=walkArray[step].y;
step++;
startNextPoint=false;
}
}
}
方法二 : TweenLite/Max 执行