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

Respawning Powerups

S

Saint Sloth

Guest
I'm new to game maker. I was following along with the Shaun Spalding platformer tutorial and did everything hid did and it turned out alright. I made a two test levels, had someone playtest them, and decided that to stupid-proof my game I need to make powerups re-spawn about 2 seconds after the alarm on them runs out. My issue is that it doesn't respawn after the alarm goes off, but the alarm deletes itself after I close the object properties folder. Here's what I have, I hope it's enough to understand.

The object file's name: obj_powerup

In a create event:
exist = 1
ypos = obj_powerup.y;
xpos = obj_powerup.x;

In a collision with player file:
with(obj_player_1)
{
jumpspeed = jumpspeed_powerup;
sprite_index = spr_player1_blue;
alarm[0] = 300;
}

instance_destroy();
exist = exist-1;

In a step file:
if (exist < 1)
{
alarm[0] = 420;
instance_create (xpos,ypos,obj_powerup);
}

Any thoughts on how to fix my issue (the item not respawning/the alarm deleting itself)?
 
S

Saint Sloth

Guest
Have you put any code in the Alarm event? An empty event generally does nothing and will be removed when you close the object window.
So the clock stopped disappearing. I have a piece of code in there that's just "///empty" so it doesn't get deleted, but how do I trigger the alarm to start running after the power up has been consumed?
 
The alarm itself doesn't do anything when it triggers. You have to put some code in the alarm, code for what you want to happen when the alarm reaches 0.
 
Top