PDA

View Full Version : [AS3] game restart/try again problems


micky_25
01-17-2010, 09:41 AM
Hey guys, basically trying to implement a game retry/restart button when the player dies and am having problems.

I have three arrays holding terrain objects, enemies and friendlies, which are all added to a "map" object.

Anyway, I tried looping through all three arrays and removing the objects from the terrain and splicing the arrays then re-generating the map with enemies,etc. This worked, but everytime a restarted the game got slower and slower. I also tried just removing all items from the stage, then re-adding them, but this also resulted in the game getting slower and slower.

Hopefully I am making some sense, any ideas on whats up, or a better way of going about this?

here is a old version of the game without the restart/retry button, but will probably give an idea of what i have to remove/regenerate

http://240887.com/game

scorpion9
01-17-2010, 12:10 PM
quite clearly u are not removing all the objects.
try tracing this.numChildren and see if it gets bigger and bigger with each restart.
and also after u have gone through all the arrays and removed the obj, dont forget to reset the array. e.g TerraynArray = [];

micky_25
01-22-2010, 10:43 PM
Hey thanks the reply, will try some things out and post back how i went
Cheers