先於元件庫製作好一個影片片段A  將此影片片段A 拉置於場景中 

點選物件此拖置於場景中的影片片段  設定影片片段名稱為MC

若是跟隨滑鼠

 

請點選拖置於場景中的物件

設定影片片段動作語法

onClipEvent(enterFrame){
this._x=this._x+(_root._xmouse-this._x)*0.2;
this._y=this._y+(_root._ymouse-this._y)*0.2;
}

 

 

若要讓他隨滑鼠方向移動轉向 則於放置此影片片段A的圖層中

再度設定動作語法為

_root.onEnterFrame = function() {
 dx = _root._xmouse-MC._x;
 dy = _root._ymouse-MC._y;
 cida = Math.atan2(dy, dx)*180/Math.PI;
 MC._rotation=cida;
}

 

即可達到效果。

 

arrow
arrow
    全站熱搜

    果 發表在 痞客邦 留言(1) 人氣()