0
你好,我正在使用Flash AS2製作一個簡單的遊戲,我不知道如何從舞臺上移除一個物體。爲什麼我的物品不能從舞臺上移開? AS2
我有所謂的「敵人」具有以下代碼的簡單對象:
onClipEvent(enterFrame) {
if (hitTest(_root.charBoy)) _root.life--;
function remove() {
this.removeMovieClip();
}
}
我再嘗試調用remove功能時,我的「子彈」物碰撞這樣的:
if (hitTest(_root.Enemy))
{
_root[Enemy].remove();
this.removeMovieClip();
}
但是唯一發生的是隻有子彈對象被移除,敵人AI停留在舞臺上。
我自己也嘗試在聲明函數以下變化:
onClipEvent(load)
{
function remove()
{
this.removeMovieClip();
}
remove();
}
onClipEvent(enterFrame) {
if (hitTest(_root.charBoy)) _root.life--;
}
和
onClipEvent(enterFrame) {
if (hitTest(_root.charBoy)) _root.life--;
function remove()
{
this.removeMovieClip();
}
remove();
}
仍然做同樣的事情。我也試過stage.removeChild(this)
,但它什麼也沒做。
請告訴我如何解決這個問題,我已經在舞臺上設置了敵人,並有簡單的AI動作,而不是以編程方式複製它們。
當我的Bullet
碰到某個物體時,我該如何將它們從舞臺上移開。
我的Bullet
對象已經可以跟蹤它們並且hits
它們使得Bullet
本身從舞臺上移除,但敵方物體仍然存在。
這看起來像AS2,AS3不按照建議。 – 2013-05-14 17:47:19
'if(hitTest(_root.Enemy)) { _root.Enemy.remove(); this.removeMovieClip(); }' – RST 2013-05-14 19:18:19