Legacy GM Keypress causes loop?

I have an object where when a key is pressed(in step event) it creates another object which also uses step event and the same key (to delete the object), that in turn causes an endless loop where the object keeps getting created right after it's deleted. I've figured out how to do this before but every time I return to game maker I forget my method.
 

dannerz

Member
in the create event, make your object "off", and when off, will not run the step.
then, use an alarm at create event, to turn the object "on" again.
Otherwise the click button keeps on looping.
 

Opticrow

Member
Create event:
Code:
Released = false;
Step event:
Code:
if Released
    {
    //Ready to delete
    if keyboard_check_pressed( DeleteKey )
        {
        //Delete
        }
    }
else
    {
    //Just spawned
    if !keyboard_check( DeleteKey )
        {
        //No longer pressed, available to delete
        Released = true;
        }
    }
 
S

Snail Man

Guest
Another option would also to make the object created on key release, so that the conflict will never happen
 
Top