8
82499
Guest
Literally the thing above
Make a variable in the create event called "invincible", set it to false. The idea is that the player will only take damage while it is false, so each time they do take damage it is immediately set to true. Then you simply check that invincible is set to true, and if so, start a timer. Once it reaches 0, invincible is set back to false, allowing the player to be damaged again.I'm not sure how to set invincibility and I'm running GM 8.1 Lite
In the collision event, you would have some code that checks if invincible is true or false. If it is false, then take damage.ok, thanks, but how do you code the part where it only takes damage when it is false?
if ( !invincible )
{
hp -= 1;
}
Instances have several built-in properties you can manipulate. You can set what is known as the sprite_index to whatever sprite you wish in order to change the appearance of the instance.also, how do you make the sprite flash while it is invincible(like mario) so the player knows it cant take damage
if ( !invincible )
{
hp -= 1;
sprite_index = spr_player_hit; // Change the sprite to the "hit" sprite.
alarm[0] = 5; // Set an alarm which will activate after 5 steps.
}
sprite_index = spr_player_normal;//Change the player sprite back to the normal one.