Skip to main content

地圖元件左右循環移動

由於龍龍仔在上上篇題問了一個關於地圖左右移動的寫法,
又剛好Erin荒廢兩個多月沒有更新,
所以就把這個簡單的移動原理在這邊公開:

說明:
1. 製作一段由A到B , B到C, C到A的連續動畫 MovieClip
2. 在這段連續動畫,僅在各自的key frame上加入action
stop();
_num=n;// 這個變數只是在告訴外面,動畫停在哪個東西上...=P

3. 當使用者按下左右鍵的時候,便執行onEnterFrame來告訴連續動畫往前跑或往後跑...=P (其實這跟倒帶的原理是一樣的)

move_mc.onEnterFrame = function() {
if (this._num != num) { //當指定的位置跟停止的keyFrame不同
if (isR) { // 如果是按右鍵
if (this._currentframe == this._totalframes) {
this.gotoAndStop(1);
} else {
this.nextFrame();
}
} else { //如果是按左鍵,,,=P
if (this._currentframe == 1) {
this.gotoAndStop(this._totalframes);
} else {
this.prevFrame();
}
}
} else {
trace("number is "+this._num);
delete this.onEnterFrame;
}
}


有興趣可以下載原始檔

Comments

Popular posts from this blog

[書評] 拖延心理學:為什麼我老是愛拖延?是與生俱來的壞習慣,還是身不由己?

作者: Jane B. Burka & Lenora M . Yuen 推薦指數 ★★★★★ 有時候,只是想了解事情發生原因而不是尋求解法 在這邊不是要講這本書的內容,而是想聊它對我的影響。