好的,所以这个框架,你躲避小行星,如果你撞到一个大的,它会摧毁你,你会去另一个框架,但是你可以选择回到前面提到的框架。有时当我重试关卡时,当我回来时,一些小行星已经留在了那里,就像这个http://imgur.com/a/o9UHC一样,似乎有时在重新加载那个场景时出现的小行星比那里更多应该。这是代码:
var speedAgainX = Math.floor(Math.random() * 20 - 10);
var speedAgainY = Math.floor(Math.random() * 20 - 10);
var speedAgainX1 = Math.floor(Math.random() * 20 - 10);
var speedAgainY1 = Math.floor(Math.random() * 20 - 10);
var speedAgainX2 = Math.floor(Math.random() * 20 - 10);
var speedAgainY2 = Math.floor(Math.random() * 20 - 10);
var speedAgainX3 = Math.floor(Math.random() * 20 - 10);
var speedAgainY3 = Math.floor(Math.random() * 20 - 10);
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();
addChild(Asteroid5);
Asteroid5.x = Math.floor(Math.random() * 20 - 10);
Asteroid5.y = Math.floor(Math.random() * 20 - 10);
Asteroid5.x = Asteroid5.x + speedAgainX;
Asteroid5.y = Asteroid5.y + speedAgainY;
if (Asteroid5.x > 1100 || Asteroid5.x < -100)
{
speedAgainX = -speedAgainX;
}
}
if(Cosmo.hitTestObject(Asteroid6)){
removeChild(Asteroid6);
nCount1++;
timer_Text1.text = nCount1.toString();
addChild(Asteroid6);
Asteroid6.x = Math.floor(Math.random() * 20 - 10);
Asteroid6.y = Math.floor(Math.random() * 20 - 10);
Asteroid6.x = Asteroid6.x + speedAgainX1;
Asteroid6.y = Asteroid6.y + speedAgainY1;
if (Asteroid6.x > 1100 || Asteroid6.x < -100)
{
speedAgainX1 = -speedAgainX1;
}
}
if(Cosmo.hitTestObject(Asteroid7)){
removeChild(Asteroid7);
nCount1++;
timer_Text1.text = nCount1.toString();
addChild(Asteroid7);
Asteroid7.x = Math.floor(Math.random() * 20 - 10);
Asteroid7.y = Math.floor(Math.random() * 20 - 10);
Asteroid7.x = Asteroid7.x + speedAgainX2;
Asteroid7.y = Asteroid7.y + speedAgainY2;
if (Asteroid7.x > 1100 || Asteroid7.x < -100)
{
speedAgainX2 = -speedAgainX2;
}
}
if(Cosmo.hitTestObject(Asteroid8)){
removeChild(Asteroid8);
nCount1++;
timer_Text1.text = nCount1.toString();
addChild(Asteroid8);
Asteroid8.x = Math.floor(Math.random() * 20 - 10);
Asteroid8.y = Math.floor(Math.random() * 20 - 10);
Asteroid8.x = Asteroid8.x + speedAgainX3;
Asteroid8.y = Asteroid8.y + speedAgainY3;
if (Asteroid8.x > 1100 || Asteroid8.x < -100)
{
speedAgainX3 = -speedAgainX3;
}
}
if (Cosmo.hitTestObject(Deathroid1)){
gotoAndStop(352, "Scene 1");
removeEventListener(Event.ENTER_FRAME,massCollect);
removeEventListener(Event.ENTER_FRAME,massGain);
removeChild(Asteroid5);
removeChild(Asteroid6);
removeChild(Asteroid7);
removeChild(Asteroid8);
}
if (Cosmo.hitTestObject(Deathroid2)){
gotoAndStop(352, "Scene 1");
removeEventListener(Event.ENTER_FRAME,massCollect);
removeEventListener(Event.ENTER_FRAME,massGain);
removeChild(Asteroid5);
removeChild(Asteroid6);
removeChild(Asteroid7);
removeChild(Asteroid8);
}
if(nCount1 == 10){
gotoAndStop(351, "Scene 1");
removeEventListener(Event.ENTER_FRAME,massCollect);
removeEventListener(Event.ENTER_FRAME,massGain);
}
}