我是动作脚本的新手,但到目前为止几乎制作了一个简单的游戏。我的问题是当我调用我的testForEnd()
函数时,加载器图像不会从那个屏幕上消失,因此我看不到我的 GAME END 屏幕。我做了一些研究removeChild()
,希望能解决我的问题,但没有奏效。任何帮助,将不胜感激!
function testForEnd():void
{
if ( score > level*30)
{
level++;
level_txt.text = String(level);
req = new URLRequest("images/" +imageNumber + ".jpg");
loader = new Loader();
imageNumber++;
loader.load(req);
addChildAt(loader,getChildIndex(settingMenu));
if( imageNumber >= 20 ) {
imageNumber = 0;
}
var tempLevelUp:LevelUp = new LevelUp();
addChild(tempLevelUp);
tempLevelUp.x = stage.stageWidth / 2 - tempLevelUp.width / 2
tempLevelUp.y = stage.stageHeight / 2 - tempLevelUp.height / 2
if (tempLevelUp.currentFrame >= tempLevelUp.totalFrames)
{
removeChild(tempLevelUp);
}
}
if (lives == 0) {
gameState = STATE_END_GAME;
}
//gameState = STATE_END_GAME;
trace(gameState);
}
function endGame():void
{
removeGame();
endScreen.visible = true;
// this is where it doesn't work loader visible
loader.visible = false;
// also i tried removeChild which didn't work
removeChild(loader);
removeEventListener(Event.ENTER_FRAME, gameLoop);
showResults();
}
function removeGame():void
{
// gameState = STATE_END_GAME;
for (var i:int = enemies.length-1; i>=0; i--)
{
removeEnemy(i);
}
for (var j:int = Lasers.length - 1; j >=0; j--)
{
removeLaser(j);
}
for (var k:int = explosions.length - 1; k >=0; k--)
{
removeExplosion(k);
}
removeChild(player);
laserTimer.stop();
}