angle = Math.atan(mousey/mousex)/(Math.PI/180); if (mousex<0) { angle += 180; } if (mousex>=0 && mousey<0) { angle += 360; } this.cannon._rotation = angle*-1; };
效果(无角度限制):
第三步:我这里设置转动的一定的角度。
Mouse.hide(); attachMovie("crosshair", "crosshair", 1); attachMovie("tank", "tank", 2, {_x:230, _y:350}); crosshair.onEnterFrame = function() { this._x = _xmouse; this._y = _ymouse; }; tank.onEnterFrame = function() { mousex = _xmouse-this._x; mousey = (_ymouse-this._y)*-1; angle = Math.atan(mousey/mousex)/(Math.PI/180); if (mousex<0) { angle += 180; } if (mousex>=0 && mousey<0) { angle += 360;
上一篇:Flash实例“蝶恋花”制作过程深入剖析
下一篇:Flash8轻松获取位图颜色代码实例教程
|