coding the endgame function

I really struggled to work out a way to end the game, I attempted using many different methods but none of these would work. I  got to the point where if there was no end point to the game there was no point of the game, so I tried to find any alternative that could work to give an impression the game had ended. I found the code where by I would completely remove the array that creates the game when the player dies.

public function gameOver():void
gameArray = null;

This code completely removed the array, and left the screen white. As it was so close to the end of the project I had to just accept this and continue with the other issues I still had to face. While working on other issues I came across some code that ended up working perfectly, this code made me create a new class which is a screen that has game over written on it, when the user dies the game over screen would appear.

public function gameOver():void
gameArray = null;

stage.removeEventListener(MouseEvent.CLICK, startGame);
var endGame:gameEnd = new gameEnd();

This was a much better solution for my issue. This method although better than the last still didn’t allow the game to work properly. I could not restart the game from this point, the game would have to be closed and re opened to start again.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s