V
vincenttnecniv
Guest
Hello. I'm sure this is an easy fix, but I can't wrap my head around how instance id's work.
Im trying to select an object and then have it deselct that object when i click on another object, or anywhere else in the room. Right now, if I click on any of the objects in the room it selects the same object every time. I can click on any instance of the object, but only one will be selected. So if I had @ @ @ in a room, and I clicked on any of them only the far right @ would be selected every time. Any insight is greatly appreciated.
My code so far is
Create Event:
selected = false;
Step Event:
if (mouse_check_button_pressed(mb_left)){
var click_id = instance_position(mouse_x, mouse_y, all);
if(click_id){
//This is where my brain just refuses to function
}
if (position_meeting(mouse_x, mouse_y, obj_card)){
//This line is suppose to deselect any previous instance and then select the new one i click
obj_card.selected = false;
selected = true;
} else if (mouse_check_button_pressed(mb_left)){
selected = false;
}
}
Draw Event:
if (selected = true){
//This just draws an outline so I know if its working or not
draw_self();
draw_sprite(spr_selected, 0, x, y);
}
else{
draw_self();
}
Im trying to select an object and then have it deselct that object when i click on another object, or anywhere else in the room. Right now, if I click on any of the objects in the room it selects the same object every time. I can click on any instance of the object, but only one will be selected. So if I had @ @ @ in a room, and I clicked on any of them only the far right @ would be selected every time. Any insight is greatly appreciated.
My code so far is
Create Event:
selected = false;
Step Event:
if (mouse_check_button_pressed(mb_left)){
var click_id = instance_position(mouse_x, mouse_y, all);
if(click_id){
//This is where my brain just refuses to function
}
if (position_meeting(mouse_x, mouse_y, obj_card)){
//This line is suppose to deselect any previous instance and then select the new one i click
obj_card.selected = false;
selected = true;
} else if (mouse_check_button_pressed(mb_left)){
selected = false;
}
}
Draw Event:
if (selected = true){
//This just draws an outline so I know if its working or not
draw_self();
draw_sprite(spr_selected, 0, x, y);
}
else{
draw_self();
}