推 peacedove:mouseX mouseY 06/13 20:14
推 p52189:要移動的東西用個Sprite包起來 然後監聽滑鼠 06/14 03:05
推 KawasumiMai:好不切實際的網站.....肥大過頭了..... 06/14 11:39
→ allenmusic:用addchild 06/14 16:15
謝謝大家!!!
最後我找了好幾本書終於找到
我現在的寫法是
var centerx:int = stage.stageWidth/2;
this.x = 0;
this.addEventListener(Event.ENTER_FRAME, mEnterFrame);
function mEnterFrame(e:Event):void {
var dx:int = stage.mouseX - centerx;
this.x -= dx*0.06;
if (this.x >0) {
this.x = 0;
} else if (this.x<stage.stageWidth-this.width) {
this.x = stage.stageWidth-this.width;
}
}
可以再請教一下
如果我想讓他在滑鼠靠近左邊以及右邊時才會移動
中間大部分的區域是不會移動的
這樣的語法該從哪裡修改呢??
目前的實力還只能套套語法而已..
謝謝大家的幫忙=)
※ 編輯: chang162015 來自: 114.32.131.113 (06/14 18:17)
推 dsmwang:用個if限制dx的設定 06/14 21:48
推 allenmusic:if(stage.mouseX>500 || stage.mouseX<50){要執行 } 06/15 06:58
→ allenmusic:500<改成你要的左邊 50改成你要的右邊範圍 -.- 06/15 06:59
推 scars:原文if裡面的大小於是不是寫反 06/15 09:48
→ scars:沒事 我看錯惹~ 06/15 09:48
真的非常感謝!!
※ 編輯: chang162015 來自: 114.32.131.113 (06/16 21:37)