private var mainFunc:Function;
function mainloop():void{ if(thisInvaderIsDeadFlag==true){ return; } if(areWeDyingFlag==true){ if(sprite.currentframe==endOfExplosionsFrame){ thisInvaderIsDeadFlag=true; } return; } moveInvader(); testForShootingAtPlayer(); testForBeingHitByPlayersBullet();}
mainFunc=mainloop_normal;function mainloop():void{ mainFunc();}function mainloop_normal():void{ moveInvader(); testForShootingAtPlayer(); testForBeingHitByPlayersBullet();}
function testForBeingHitByPlayersBullet():void{ if(playerBullet.hitTest(thisInvaderSprite)){ thisInvaderSprite.gotoAndPlay("firstExplodingFrame"); mainFunc=mainloop_waitingToDie; }}
function mainloop_waitingToDie():void{ if(sprite.currentframe==endOfExplosionsFrame){//Kill this invader totally, ie remove the mc mainFunc=null; }}
Disclaimer The opinions expressed herein are our own personal opinions and do not represent our client's views in any way.