When you pick an item in the inventory and drop it to obj_item_ground, this item is send to the ground. That's fine.
I want to add a delay to this item to destroy it, but if I drop 2 items to the ground, only the last is destroy.
Question : How can I create one timer by item dropped ?
Step :
obj_inventory : on Create event
instance_create(0, 0, obj_item_ground);
obj_item_ground : on Create event
initialTime = 5;
time = 5;
ground = -1;
on Alarm[0] event; if timer is less than 0, object is destroy.
if (time > 0) {
time -= 1;
alarm[0] = 30;
} else {
with (ground) {
instance_destroy();
}
}
on Left Pressed event :
if (mouseItem != -1) {
scr_item_ground_timer();
}
mouseItem is item I drag to the obj_item_ground.
scr_item_ground_timer() :
Here I create the instance of object dropped to the ground and start the alarm[0] timer.
scr_inventory_item_drop(mouseItem);
for (i = 0; i < mouseQuantity; i++) {
ground = instance_create(obj_player.x + random_range(-30, 4), obj_player.y + random_range(-12, 0), mouseItem);
}
alarm[0] = 30;
mouseItem = -1;
scr_inventory_item_drop is just to clear the array which contains the object dropped.
with (ground) instance_destroy();? This means the ground will be destroyed, not the object that is the owner of the timer. \$\endgroup\$