Hi ,
I don't know how to secure if I shoot all the intruders,
I change the room, I return, the invaders come back to life.
When I click the persistent, the invaders remain dead,
but the living ones follow me to the second room
)
GameMaker has object/instance persistence and room persistence.
It sounds like you tried to use object persistence.
I disrecommend using room persistence in general.
In this case, I'd also disrecommend using object persistence, because you should only use object persistence to bring an object along with you to an other room.
Last time I checked, GameMaker assigns constant instance identifiers to instances placed inside the room editor.
You can use this to keep track of which intruders have been shot in some global ds_map and check that in the intruders' create event and make them destroy themselves if they have been shot before.
It could look something like this:
In some initialization room at the start of your game, you execute this in the room creation event:
GML:
// Set of shot intruders: initially empty
global.shot_intruders_set = ds_map_create();
room_goto_next();
In the create event of the intruder objects:
GML:
// Check if intruder has been shot already
if !is_undefined(global.shot_intruders_set[?id]) {
instance_destroy();
}
In the destroy event of the intruder objects:
GML:
// Mark this intruder as being shot
global.shot_intruders_set[?id] = true;
I hope this helps!
Feel free to ask any questions you have!