• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Opening an interactable window clicking on an instance

Lucouss

Member
Hello guys,

In my game I have objects (upgradable "turrets"), if I click on those it opens a new tab that lets me upgrade the clicked one. To do that I wrote this code:

pTurret - Left Pressed:
GML:
_id = instance_position(mouse_x, mouse_y, pTurret);
instance_create_layer(1056, 576, "Instances", oTab);

oTab - Left Pressed:
GML:
with(pTurret._id) {
    // Do stuff
}

But doing so, it keeps the id of the first turret created.
So I tried to fix that, moving the id_get in the Step Event:

pTurret - Step Event
GML:
if(mouse_check_button(mb_left)) {
    _id = instance_position(mouse_x, mouse_y, pTurret);
}
This works better, but now I have another problem: if I click on the tab it's like I click on the instances under the window too.
I don't want to deactivate instances in that region because it generates errors using those ids.

I have no idea how to fix this, maybe using a variable. But I tried in that way and it didn't work, could you guys help me? Thanks!
 
Top