所以,我正在尝试做这样的事情,如果Cosmo.hitTestObject,Asteroid 5应该被删除,但我希望它立即添加回不同的位置,因此命中测试不会自动触发。我该怎么做呢?
var nCount1:Number = 0;
timer_Text1.text = nCount1.toString();
addEventListener(Event.ENTER_FRAME,massCollect);
function massCollect(e:Event) {
if (Cosmo.hitTestObject(Asteroid5)) {
removeChild(Asteroid5);
nCount1++;
timer_Text1.text = nCount1.toString();
}
if (nCount1 == 5) {
gotoAndStop(351, "Scene 1");
removeEventListener(Event.ENTER_FRAME,massCollect);
}
}
答案 0 :(得分:0)
我会选择这样的东西:
var nCount1:Number = 0;
timer_Text1.text = nCount1.toString();
addEventListener(Event.ENTER_FRAME, massCollect);
function massCollect(e:Event) {
if (Cosmo.hitTestObject(Asteroid5)) {
while (Cosmo.hitTestObject(Asteroid5) {
Asteroid5.x = Math.floor(MAX_WIDTH * Math.random());
Asteroid5.y = Math.floor(MAX_HEIGHT * Math.random());
}
removeChild(Asteroid5);
nCount1++;
timer_Text1.text = nCount1.toString();
}
if (nCount1 == 5) {
gotoAndStop(351, "Scene 1");
removeEventListener(Event.ENTER_FRAME, massCollect);
}
}