我正在制作一个游戏,用户点击昆虫,并试图获得一个很好的高分。当用户单击一只昆虫时,该昆虫会播放一段动画,并在下面的代码中停留2秒:
import flash.events.MouseEvent;
import flash.display.MovieClip;
import fl.motion.Animator;
import flash.events.*;
play();
var mysound:squish = new squish();
this.addEventListener(MouseEvent.CLICK, kill);
this.dead = false;
function kill(e:MouseEvent):void
{
this.dead=true;
mouseChildren=false
mysound.play();
gotoAndPlay(21);
this.removeEventListener(MouseEvent.CLICK, kill);
flash.utils.setTimeout(removeSelf,2000);
}
function removeSelf():void
{
this.parent.removeChild(this);
}当用户暂停游戏时,敌人就会停止,他们就会隐形。唯一的问题是,当用户点击昆虫,并点击暂停按钮,昆虫停留在那里2秒。当玩家暂停游戏时,我如何移除计时器,使屏幕上没有昆虫?
发布于 2013-11-29 13:51:48
以下是一些小贴士:
this.parent.removeChild(this); is https://stackoverflow.com/questions/20278993
复制相似问题