Windows SOLVED (Invincibility - Asteroid)

J

Jossemann

Guest
Hello folks.

I've just started with GML. Currently running trial for testing.
I have been following Shaun Spalding' s tutorials.

- im at the last step.

Since this tutorial is in GM1, I had to do some modifications especially with instance_create.

Anyways. When I follow the guide for making my ship invincible at spawn I end up with the whole collition event not functioning.


Here is what I have done to achieve this.(following the tutorial)

Created a sprite that animates (blinks)
Set this as default to my player object, created an alarm that changes the sprite to the normal with:

sprite_index = spr_Asteroid_Player

This looks good. When I start the game the player object is blinking as intended. After a few seconds it returns to my static sprite.




PROBLEM?
**************

if (sprite_index == spr_Asteroid_Player)

{

var randomangle = random(360);
var o;

o = instance_create_depth(x,y,depth -200, obj_dead_player);
o.angle = 0 + randomangle;
o = instance_create_depth(x,y,depth -200, obj_dead_player);
o.angle = 120 + randomangle;
o = instance_create_depth(x,y,depth -200, obj_dead_player);
o.angle = 240 + randomangle;


with (obj_dead_player)

{
direction = angle;
image_angle = angle;
speed = 3;

}

audio_play_sound(snd_deadplayer,10,0)


if (global.life > 0)

{
global.life -= 1;
instance_create_depth(room_width/2,room_height/2,-200,obj_Player)
}

else
{

instance_create_depth(0,0,-250,obj_GameOver)
}

instance_destroy(other);

}


**************


With the code over the player object is not getting damaged either blinking or not.
If I remove the:

if (sprite_index == spr_Asteroid_Player)


Both my blinking and not blinking player object gets destroyed.

Can anyone shed some light on what's wrong with the code?

I'm suspecting the sprite_index is not working as I want. Am i wrong?



br
jossemann
 
J

Jossemann

Guest
I found out I had to write this instead:

if obj_Player.sprite_index = spr_Asteroid_Player
 
Top