2015-01-13 83 views
0

我使用的是actionscript 2.0,我有一個正沿着x軸運行的影片剪輯,並給出它們的每個邊界。而且我還有一個用於我的遊戲動畫的動畫片段。如果三個動畫片段到達其給定的邊界,則三個動畫片將變爲0並且應該繼續到下一個幀。我的問題是,我gotoandstop的代碼不起作用。Actionscript 2.0 gotoandstop

這裏是我的影片剪輯代碼:

onClipEvent (load) { 
speed = 5; 
boundary = 280;  
} 
onClipEvent (enterFrame) { 
if (this._x > boundary) { 
    this._x -= speed;  
} 
else { 
    this._x = boundary; 
    _parent.life -= 1; 
    _parent.lifebox.text = _parent.life; 

    this.swapDepths(0); 
    this.removeMovieClip(); 
    delete this.onEnterFrame; 

} 
} 

這是我爲我的時間軸代碼:

stop(); 
var keyListener:Object = new Object(); 
var life:Number = 3; 

keyListener.onKeyDown = function() { 


if (textbox.text == "ant"){ 
ant_mc.swapDepths(0); 
ant_mc.removeMovieClip(); 
bee_mc._x +=40; 
bug_mc._x +=40; 

} 

if(life == 0){ 
gotoandstop(1); 
} 

if (Key.isDown(Key.ENTER)) { 
textbox.text=""; 

} 

}; 
+0

爲什麼使用 var life:Number = 3; 而不是 var life = 3; 此外,我不會將這些變量放在時間軸上,而是讓屏幕外的對象保存這些數字並控制幀移動。 (在movieclip類中使用_root引用它) – Aify

+0

除了條件'if(life == 0){gotoandstop(1);}',我的所有代碼都可以工作,以繼續下一幀。 –

回答

0

嘗試從時間軸檢查移動到的onEnterFrame()。我看到它的方式,只有當一個鍵被關閉時纔會運行檢查,所以你永遠不會檢查它。我認爲你需要檢查每一幀是否爲life == 0