• 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!

GameMaker instance_destroy looping problem

FacesOfMu

Member
I've got this UI object that tests at the end of the DrawGUI event whether the instance is still showing to screen, and if not
Code:
 event_perform(ev_destroy,0);
In the Destroy Event, it calls the destroy event of some other UI objects it was controlling, and then at the end
Code:
 instance_destroy(id, false);
The problem I seem to be having is that the first "master" UI instance seems to run another loop of DrawGUI and crashes when it gets to the first reference of one of it's previously destroyed sub-instances.
I even output the ID of the instances at the start and end of the DrawGUI event and destroy event and the ids match as the same object.

So in my output it goes:
Code:
"Start of ui_obj 100130 DrawGui"
//...a bunch of drawgui code

//...passes test to call ev_destroy
event_perform(ev_destroy,0);
    "Begin ui_obj  100130 Destroy"
    //...destroy other sub-instances
    instance_destroy(id, false)
    "End ui_obj 100130 Destroy"
"End of ui_obj  100130 DrawGui"

"Start of ui_obj 100130 DrawGui"
(CRASH)
What is it about this destroy cycle that I'm not understanding?
 
Last edited:

FacesOfMu

Member
Blech! I think I figured it out. Another bit of code was forcefully calling the instance's drawgui event. All good!
 
Top