• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android Attempt at destroying all of one instance failure

Erayd

Member
I'm looping through all of the available enemy objects currently existing in the room and destroying them one by one. In theory anyway, since that's not what's happening. Actually for some odd reason only some of the enemy objects are disappearing. Any thoughts as to why?

Code:
if(instance_exists(obj_Enemy)){
                    var k = 0;
                    var _mob = 0;
                    for(k = 0; k < instance_number(obj_Enemy); k++){
                       _mob = instance_find(obj_Enemy, k);
                       with(_mob) instance_destroy();
                   }
}
 

Erayd

Member
Its just what my mind put together first before looking elsewhere for another option. So does the code you provided just delete every instance of object enemy? I suppose it makes sense that it would.

Edit: Just tested it out, thanks for that. It worked. I'll remember that for the future.
 
Last edited:
Top