A
Agletsio
Guest
What I want to happen:
When I press the button, a red cross appears over it (image_index = 1). After this, the sprite should stay in that state as it has already been pushed. So basically the button can only be pressed once.
With my current code I, the sprite only stays in that state for one frame and then reverts back to image_index = 0. I assume this is because of my "else" argument becoming true in the following frame(because of keyboard_check_pressed). So I can see the problem but I have no idea hot to get around it and couldn't find anything on the web that provided clarity.
(the objects are created by a obj_room_control via instance_create. obj_dreams is the name of one of the buttons)
This seems like such a simple thing but having a lot of trouble with it. Any help or guidance will seriously be appreciated!
obj_dreams Create Event:
obj_dreams Step Event:
obj_dreams Draw Event:
When I press the button, a red cross appears over it (image_index = 1). After this, the sprite should stay in that state as it has already been pushed. So basically the button can only be pressed once.
With my current code I, the sprite only stays in that state for one frame and then reverts back to image_index = 0. I assume this is because of my "else" argument becoming true in the following frame(because of keyboard_check_pressed). So I can see the problem but I have no idea hot to get around it and couldn't find anything on the web that provided clarity.
(the objects are created by a obj_room_control via instance_create. obj_dreams is the name of one of the buttons)
This seems like such a simple thing but having a lot of trouble with it. Any help or guidance will seriously be appreciated!
obj_dreams Create Event:
Code:
dream_pushed = false;
dream_text = false;
obj_dreams Step Event:
Code:
if place_meeting(x,y,obj_pointer) && dream_pushed = false {
dream_text = true;
}
else
dream_text = false;
if place_meeting(x,y,obj_pointer) && keyboard_check_pressed(vk_space) {
dream_pushed = true;
}
else
dream_pushed = false
if dream_pushed = true {
image_index = 1;
}
if dream_pushed = false {
image_index = 0;
}
obj_dreams Draw Event:
Code:
draw_self();
if dream_text = true {
draw_set_halign(fa_center)
draw_text(x,y+80,"Press'SPACE' to push button")
}