M
Medieval Ducky Official
Guest
I'm making a fan game of fnaf (I'm not going to talk about what it is) And I'm trying to make the door function (I've done the sprites for the door buttons and the door closing). How do I program it to close?
Now what about the button that closes it?Create event. [obj_door]
door_state = "closed";
Step event
If door_state = "closed"
{sprite_index = spr_door_closed;}
If door_state = "open"
{sprite_index = spr_door_open;}
Two. Red for opened door and green for closed.Ok in your open button object
And select the mouse left click event
Then put this code
{obj_door.door_state = "open";}
how many buttons are you using for the door and are they seprate objects?
Alright then, thanks for the help!Ok for the green button do the same code except make door_state = "closed"
I'm a little confused about the sprite index part, to be honest -_-.To change the red button to green there are a few ways. One is to have a button sprite with 2 images(image 0 being a red button and image 1 being the green button) set the image_speed and image_index to 0 in the create event of the button. when you want to display the green button, Just set the image_index to 1.
Or, you could Just have two different sprites, One red button, One green button. in your button object, set the sprite_index to the sprite you want to display.
I don't get it :|Read the example code you were given carefully. You haven't followed it exactly.
Compare this with your code and find the difference. That is what is causing the error.Ok for the green button do the same code except make door_state = "closed"
What......Compare this with your code and find the difference. That is what is causing the error.
Alright, Thanks for the help.I figure everyone has to start somewhere. I think that for what you are trying to achieve, it might be valuable for you to go through some of the gamemaker tutorials if you haven't already done so. They may help clear up a lot of the stuff you are trying to do here.