Re: [問題] 隨機跳躍

看板Flash作者 (lol)時間18年前 (2007/05/23 12:40), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/4 (看更多)
※ 引述《KazuhaToyama ()》之銘言: : 要一個Movie Clip 在800,600之中隨機跑來跑去 : 可以設定 : onClipEvent (enterFrame) { : this._x = math.random()*800; : this._y = math.random()*600; : } : 但是我發現他跳動的速度很快 : 要他跳一個地方停三秒的話,要怎麼寫呢^^ : 謝謝 另外有個東西可以用: getTimer() : Number 傳回從開始播放 SWF 檔起所經過的毫秒數。 var timer:Number = getTimer(); var duration:Number = 3000; // 要停留的時間,毫秒 this.onEnterFrame = function(){ if(getTimer() - timer > duration){ timer = getTimer(); this._x = Math.random()*800; this._y = Math.random()*600; } } 希望能有幫助 ^^" -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.80.237.118
文章代碼(AID): #16KyMz33 (Flash)
討論串 (同標題文章)
文章代碼(AID): #16KyMz33 (Flash)