我有一个游戏,其中一个航班将射击子弹,当子弹击中一艘敌舰时,一个爆炸效果来临,另一个框架加载。现在我面临的问题是爆炸效果,下一帧正在加载。所以,我添加了这个脚本:
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);
}
}
但结果仍然相同。我也试过增加时间,但我仍然无法阻止另一帧暂停。请帮帮我。谢谢
答案 0 :(得分: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);
}
}