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

Legacy GM Keypress causes loop?

N

NateTheGreat

Guest
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.
 
O

Opticrow

Guest
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