I
iBack
Guest
Hi, I'm still new to GML and I need help with multiple coin drops in position of where the enemy is destroyed.
I have achieved this in some way, once I destroy multiple enemy in radius coins is dropped in its destroyed position however some times more coins is dropped in another position after the enemies are destroyed.
Here is the code in the collision event:
as you can see this works once I create a instance_create_layer.
the problem i have is, some times once i destroy the instance the coins appear in position of enemy being destroyed but coins will also appear across the stage (no the radius of the attack does not reach that side of the stage so i dont understand why more coins are appearing).
Hope someone can help. Thank you.
I have achieved this in some way, once I destroy multiple enemy in radius coins is dropped in its destroyed position however some times more coins is dropped in another position after the enemies are destroyed.
Here is the code in the collision event:
GML:
var _list = ds_list_create();
var _num = collision_circle_list(x, y, 200, obj_enemy, false, true, _list, false);
if _num > 0
{
for (var i = 0; i < _num; ++i;)
{
with (obj_enemy){
if (invincible = false) {
instance_create_layer(x,y,"CoinPickup",obj_coin2);
instance_destroy(_list[| i]);
}
}
}
}
ds_list_destroy(_list);
the problem i have is, some times once i destroy the instance the coins appear in position of enemy being destroyed but coins will also appear across the stage (no the radius of the attack does not reach that side of the stage so i dont understand why more coins are appearing).
Hope someone can help. Thank you.
Last edited by a moderator: