Imiglikos
Member
Hello everyone,
I have many enemies in the game and I have created an object for each of them separately so that each enemy can respawn after death. Is there a way for me to have only one object to respawn enemies? instead of creating dozens of objects?
Thank you in advance for helping everyone.
currently the code looks like this
obj_enemy
create
step
obj_respawn_enemy
create
alarm[0]
step
I have many enemies in the game and I have created an object for each of them separately so that each enemy can respawn after death. Is there a way for me to have only one object to respawn enemies? instead of creating dozens of objects?
Thank you in advance for helping everyone.
currently the code looks like this
obj_enemy
create
GML:
dead=false;
step
GML:
if hp <= 0 {
instance_destroy();
dead=true;
with instance_create(x,y,obj_entity_die)
{
sprite_index = spr_enemy_die;
image_speed=1;
image_xscale = other.image_xscale;
image_yscale = other.image_yscale;
audio_play_sound(snd_enemy_die, 1, false);
}
}
// respawn enemy
if (dead == true)
{
instance_create(x,y,obj_respawn_enemy);
}
obj_respawn_enemy
create
GML:
alarm[0]=20*room_speed
dead = false
alarm[0]
GML:
instance_create(x,y,obj_enemy)
step
GML:
if (dead = true)
{
alarm[0] = 90
dead = false
}