B
Braeden Hammill
Guest
I'm making a game where there are doors that open when a specific button is being pressed and close when the button is not being touched.
I have made it so if the button is pressed it will open every door object, and my problem is I can't figure out how to give a specific button a relationship with a specific door, I've tried it once where in the step event it checks if the door and button both have a variable in common where I give them both a variable in the creation code and if I want button "A" to work with door "A" and button "B" to door "B" then the "A" buttons and "A" doors would have their variable equal "1" and the "B"'s would both equal "2". ( It didn't work )
Pls help (I have only been coding for a few months so I am not an expert)
Door Code: (without the variables that it and the button will have in common. All it says is "if button pressed, move door up, if not, move door down. pls tell me how to make a certain button activate a certain door.)
obj_door_move
_mspd = 1
_vspd = 0
if obj_button._state = obj_button._pressed
{
if y != ystart - 112
{
_vspd = _mspd
y -= _vspd
}
}
else
{
if y != ystart
{
_vspd = _mspd
y += _vspd
}
}
obj_button
_state = 0;
_pressed = 1 // if button is being touched/pressed
_notpressed = 2 //if the button was previously pressed but is now not being touched/pressed
if place_meeting(x,y,obj_player) || place_meeting(x,y,obj_box)
{
_state = _pressed
sprite_index = spr_button_press
}
else
{
_state = _notpressed
sprite_index = spr_button
}
I have made it so if the button is pressed it will open every door object, and my problem is I can't figure out how to give a specific button a relationship with a specific door, I've tried it once where in the step event it checks if the door and button both have a variable in common where I give them both a variable in the creation code and if I want button "A" to work with door "A" and button "B" to door "B" then the "A" buttons and "A" doors would have their variable equal "1" and the "B"'s would both equal "2". ( It didn't work )
Pls help (I have only been coding for a few months so I am not an expert)
Door Code: (without the variables that it and the button will have in common. All it says is "if button pressed, move door up, if not, move door down. pls tell me how to make a certain button activate a certain door.)
obj_door_move
_mspd = 1
_vspd = 0
if obj_button._state = obj_button._pressed
{
if y != ystart - 112
{
_vspd = _mspd
y -= _vspd
}
}
else
{
if y != ystart
{
_vspd = _mspd
y += _vspd
}
}
obj_button
_state = 0;
_pressed = 1 // if button is being touched/pressed
_notpressed = 2 //if the button was previously pressed but is now not being touched/pressed
if place_meeting(x,y,obj_player) || place_meeting(x,y,obj_box)
{
_state = _pressed
sprite_index = spr_button_press
}
else
{
_state = _notpressed
sprite_index = spr_button
}