T
theGRIM
Guest
I'm making a tower defense. I'm trying to make it so that when you click on a tower, a menu is created, and when you click on another tower, the first menu is deleted and a new one is created on the tower that is clicked on. I'm trying to do it in the parent object for the towers. Here is my code:
object "objtowerparent" event "mouse global left pressed"
"canselect" is if the mouse cursor is hovering above the tower or not. It changes with the [mouse enter] and [mouse leave] events.
It works fine when you just have 1 tower created, but when i create more towers, the menu only works for the last one I've created. Any ideas for why this is happening? Is there a better way to do this? Thanks in advance.
object "objtowerparent" event "mouse global left pressed"
Code:
with (objtowermenu) { instance_destroy(); }
if canselect == 1 then
{
instance_create(x,y,objtowermenu);
}
It works fine when you just have 1 tower created, but when i create more towers, the menu only works for the last one I've created. Any ideas for why this is happening? Is there a better way to do this? Thanks in advance.