• 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!

Legacy GM [Solved] Check if object was clicked

L

Lunara

Guest
hi all,
i need a little help again, :(
---
Object_2 can only be clicked on if I clicked object_1 before.
---
Any suggestions how this can be done? I cant get this to work properly, help would be aprreciated.
 
T

TDSrock

Guest
Set a flag in object_1 that is called clicked.
Set it too false at the start. when clicked set it to true.
When in object_2 gets clicked check the state of object_1s flag
 
L

Lunara

Guest
Cant get the last part to work correctly: When in object_2 gets clicked check the state of object_1s flag.

any hints? :-/
 
L

Lunara

Guest
It worked now but I dont know if this is the best way, i did it like this:

obj_one
create_event
global.clicked = false;

left_pressed
global.clicked = true;

obj_two
left_pressed
if(global.clicked = true) {
instance_destroy()
}
 
T

TDSrock

Guest
This is an method but I would use object accesors instead of a global variable.

Here is an example(plus how I would create the second button).

Code:
//create event obj_button_1
clicked = false;
buttonLinkedToo = instance_create(x + 50, y - 50, obj_button_2);//creates a the second button 50 pixels to the left and 50 pixels up relative to this button).
buttonLinkedToo.clicked = false;

//step event obj_button_1
if(/*clicked on*/){
   if(buttonLinkedToo.clicked){
      //do whatever we need to do when both buttons have been pressed
   }
}

//step event obj_button_2
if(/*clicked on*/){
   clicked = true;
}
Now I have given waaay more code then I normally would and it's also very targeted at your problem... Note that "/*"and "*/" are there to contain a comment. Whatever is within them you still need to sort out yourself(there are several ways of doing that, per example through the events you did, but I don't think they keep in mind that they are clicked ontop of.)
 
Last edited by a moderator:
L

Lunara

Guest
thanks for your response and your effort, TDSrock, I will have a closer look into it.
Although I think for now I will stick with the other solution, I modified it a little and it works just fine for me.
 
Top