L
Lori
Guest
Hey,
I seem to be missing something glaringly obvious about instances :-/
I have two instances of the same object in my room but they only appear after text input by the user (so I cannot put the instances in via the room GUI Editor or else they'd appear right away).
The instances are buttons and I want them to perform different things when clicked.
This task was easy enough for another set of buttons that were there right when the room stared - I just used the instances' "Creation Code" accessed via right click in the room editor and entered
and btn2_clicked = true for the second button.
How can I access this function in code directly, without the GUI?
Or how can I reference each of two instances (of the same object in one room) in a mouse event? What am I missing here?
This is what I had:
And then I tried to use that checkYesNo variable in the object obj_btn_answerCheck's mouse event...which of course did not work, because why would it...
Game Maker Studio 1.4
I seem to be missing something glaringly obvious about instances :-/
I have two instances of the same object in my room but they only appear after text input by the user (so I cannot put the instances in via the room GUI Editor or else they'd appear right away).
The instances are buttons and I want them to perform different things when clicked.
This task was easy enough for another set of buttons that were there right when the room stared - I just used the instances' "Creation Code" accessed via right click in the room editor and entered
Code:
if mouse_check_button_released(mb_left) then btn1_clicked = true
How can I access this function in code directly, without the GUI?
Or how can I reference each of two instances (of the same object in one room) in a mouse event? What am I missing here?
This is what I had:
Code:
//"yes" button
var btnCheckAnswerY = instance_create (220,356,obj_btn_answerCheck);
btnCheckAnswerY.answerCheck = "Yes"; //This fills the button's text variable
btnCheckAnswerY.checkYesNo = 1; //put this in to use for drawing one of two sprites for the button
//"no" button
var btnCheckAnswerN = instance_create (370,356,obj_btn_answerCheck);
btnCheckAnswerN.answerCheck = "No";
btnCheckAnswerN.checkYesNo = 0;
Code:
if checkYesNo = 1 //if YES has been clicked
{
score += 1;
room_goto(rm_00_Congratulations);
}
if checkYesNo = 0 //if NO has been clicked
{
room_goto(rm_00_TooBad);
}