Legacy GM bar advance when click on button

O

ocimpean

Guest
I made few buttons with condition switch to navigate between rooms.
Also made second object like a health bar, but I want it to show when the condition switch buttons are clicked and deduct points from global.ex variable.
When counter reaches zero, I would like to go to room_9. Also, I would like the counter bar to be persistent between rooms (so I will convert probably it to draw gui), also I want it to remember the number of points deducted on click from another room, if I decide to navigate between rooms.

And is not working.
By that I mean the counter-bar is drawn, but clicks are not registered.
I am using the code written below, and I would like to ask if any of you more experienced users you can have a look and help me make it work.
Thank you.



//object_button--------------#-----------------------------------------------------
//draw-_-_-_-_
draw_self();
draw_set_colour(c_black);
draw_set_valign(fa_middle);
draw_set_halign(fa_center);
draw_set_font(font1);
draw_text(x,y,text);

//create-_-_-_-
image_speed = 0
global.ex = 100;
global.maxex = 100;
// on left released-_-_-_-_
global.ex = global.ex - 10;
if (global.ex <= 0)
{
room_goto (room_9);
}
switch (action)
{
case 0:

room_goto(room_1);
break;

case 1:
room_goto(room_2);
break;

case 2:
room_goto(room_9);
break;
}

//object_click_button_bar -------------------------------------------------------
//draw
//_-_-_-_
drawWidth = 250;
draw_set_colour(c_yellow);
draw_rectangle(250, 550, 250+(global.ex/global.maxex)*drawWidth , 550+20, false );
draw_set_colour(c_green);
draw_rectangle(250, 550, 250+drawWidth , 550+20, true );
//--------------------
 

Vallo92

Member
Sorry but i write on my phone.
Try this:
Code:
On click:

global.ex -= 10;
Switch (global.ex) {
case 0:
room_goto(room_9);
break;
case 10:
room_goto(room_8);
break;
case 20:
........
case 30:
.....
}
 
Do you re-create the object that defined "global.ex" on every room? because if so it will reset global.ex to 0 each time you switch rooms.
 
O

ocimpean

Guest
Do you re-create the object that defined "global.ex" on every room? because if so it will reset global.ex to 0 each time you switch rooms.
I removed it. But no clicks are registering. I must be doing something wrong
 

Vallo92

Member
I removed it. But no clicks are registering. I must be doing something wrong
so the problem is that no clicks are detected?
try inserting a show_debug_message at the beginning of the click event and see if the debug message is shown in the console. if nothing is shown, the problem lies there.
 
O

ocimpean

Guest
Thanks for the debug advice, I will look into it. Sorry for the late answer.
In the mean time, to simplify my life and finish this project, I already built individual buttons without condition switch, that are doing the job and ditched the global thing altogether.
 
Top