Hi there! Here's a suggestion:
Move the collision from the asteroid object to the player ship object. In that event, instead of changing the object to explosion (which is terrible practice and was going to be removed from the engine), just create an explosion object at its position. Then reset [snip]x[/snip] to [snip]xstart[/snip] and [snip]y[/snip] to [snip]ystart[/snip] instead of creating the new ship.
In the ship's create event, set a variable, such as [snip]invincible[/snip], to 0. Then, wrap the collision with asteroid event you created in [snip=edl]if (invincible <= 0) {}[/snip]. Also in that [snip]if[/snip] block, set [snip=edl]invincible = room_speed * 3;[/snip] to give you three seconds of invincibility. In the step event, decrement it:
if (invincible > 0) invincible -= 1;
That should do it.
Alternatively, you can set an alarm whose job it is to unset [snip]invincible[/snip] instead of decrementing it yourself. Instead of setting [snip]invincible[/snip], you would use [snip=edl]invincible = true; alarm[0] = room_speed * 3;[/snip]. Alarm0 would then reset [snip]invincible[/snip] to false.
|