我有一个Flash射击游戏,当用户拍摄一个瓶子后,我播放销毁动画并将其从屏幕上移除。问题是当用户点击的速度太快时,就像超人一样快速进入该方法两次,无论如何。有谁知道如何解决这个问题?如何在点击对象后禁用鼠标点击?
下面是代码:
public function bottleHasClicked(bottle : BottleBase) : void {
bottle.mouseEnabled = false;
collectedBottles++;
bottlesInRound--;
gameSound.getShootSound().playSound();
gameSound.getBottleSound().playSound();
ArrayUtil.removeValueFromArray(elementsInScreenArray, bottle);
cleanElementsTimer[bottle].stop();
delete cleanElementsTimer[bottle];
if (bottlesInRound == 0) {
stopElementsTimer();
showElementsWaitForSeconds(0.5);
}
createBulletHole();
bottle.play();
}
我做的第一件事是禁用对象的鼠标,它仍然会发生。我只有在我要再次展示瓶子时才能启用它。
你是如何要求这种方法? –