2

我有一个游戏,其中一架飞机会发射子弹,当子弹击中敌舰时,会出现爆炸效果并加载另一个帧。现在我面临的问题是爆炸效果和下一帧一次加载。所以,我添加了这个脚本:

if (this.hitTest(_root["enemy1"])) {
    this.removeMovieClip();
    _root.enemy1._x=2000;
    _root.option1._x=2000;
    addExplosion(800, 200, explosionParticleAmount, explosionDistance, explosionSize, explosionAlpha);
    this._x=-900000;
    var sound:Sound = new Sound(this);
    sound.attachSound("explode");
    sound.start();
    flag = true;
    wait();
    checkAnswer(_root.option1.text);
}

function wait() {
  stop();
  var myInterval = setInterval(function () {
      play();
      clearInterval(myInterval);
  }, 5*1000); // stop for 5 seconds
}

function checkAnswer(answer){
  if(questions[level][1] == answer){  
     status_flag=true;
     score=score+10;
     bullet_fire=false;
     gotoAndStop(3);
  }else{
      bullet_fire=false;
     gotoAndStop("Scene 2",1);
  }
}

但结果还是一样。我也尝试增加时间,但我仍然无法阻止另一帧暂停。请帮帮我。谢谢

4

1 回答 1

1

我认为以下内容应该对您有用,尽管更强大的方法是暂停,直到您收到一个表明您的爆炸动画已完成的事件。当前方法的问题在于,如果您更改爆炸序列的长度,您还需要记住更新暂停的长度。

if (this.hitTest(_root["enemy1"])) {
    this.removeMovieClip();
    _root.enemy1._x=2000;
    _root.option1._x=2000;
    addExplosion(800, 200, explosionParticleAmount, explosionDistance, explosionSize, explosionAlpha);
    this._x=-900000;
    var sound:Sound = new Sound(this);
    sound.attachSound("explode");
    sound.start();
    flag = true;
    wait();
}

function wait() {
  stop();
  var myInterval = setInterval(function () {
      //play();
      checkAnswer(_root.option1.text); // check answer after explosion has finished
      clearInterval(myInterval);
  }, 5*1000); // stop for 5 seconds
}

function checkAnswer(answer){
  if(questions[level][1] == answer){  
     status_flag=true;
     score=score+10;
     bullet_fire=false;
     gotoAndStop(3);
  }else{
      bullet_fire=false;
     gotoAndStop("Scene 2",1);
  }
}
于 2012-10-18T16:26:27.837 回答