D
Dushi
Guest
Hello guys,
I have GUI buttons made with virtual keys. How GUI looks: There are "layers" of GUI buttons. Layer 0 - base buttons, Layer 1 - buttons for units, Layer 2 - buttons for support stuff(but it really doesn't matter what they are for). So when I enter a room the layer 0 is shown. If I click on first button, the layer 0 will disappear and layer 1 will be shown. If I click on "back button", layer 1 will disappear and layer 0 will be shown. Same with layer 2. Problem: In some rooms it doesn't work properly(all rooms have same settings). I can't click on first button but I can click on second button for layer 2. When I click on "back button" for layer 0, it will not show layer 0 but layer 1(check step code below and you will understand why it should not happen). Using show_debug_message I found out that when I click on "back button" it will show layer 0(but human eye cannot see it) and immediately show layer 1. Check code:
Create event:
Step event:
Draw GUI units:
If I press numpad keys in there problematic rooms, it works well. EDIT: I know there may be problem with overlapping but why does it work in some rooms?
I have GUI buttons made with virtual keys. How GUI looks: There are "layers" of GUI buttons. Layer 0 - base buttons, Layer 1 - buttons for units, Layer 2 - buttons for support stuff(but it really doesn't matter what they are for). So when I enter a room the layer 0 is shown. If I click on first button, the layer 0 will disappear and layer 1 will be shown. If I click on "back button", layer 1 will disappear and layer 0 will be shown. Same with layer 2. Problem: In some rooms it doesn't work properly(all rooms have same settings). I can't click on first button but I can click on second button for layer 2. When I click on "back button" for layer 0, it will not show layer 0 but layer 1(check step code below and you will understand why it should not happen). Using show_debug_message I found out that when I click on "back button" it will show layer 0(but human eye cannot see it) and immediately show layer 1. Check code:
Create event:
Code:
//Layer 0 - Base
guiBase[0] = spr_guiUnits;
guiBase[1] = spr_guiSupport;
//Layer 1 - Units
guiUnit[0] = spr_guiBack;
guiUnit[1] = spr_guiRifle;
guiUnit[2] = spr_guiOfficer;
guiUnit[3] = spr_guiFlame;
guiUnit[4] = spr_guiSniper;
guiUnit[5] = spr_guiMG;
//Layer 2 - Support
guiSupport[0] = spr_guiBack;
guiSupport[1] = spr_guiArtillery;
guiSupport[2] = spr_guiGasMask;
guiSupport[3] = spr_guiGas;
//Virtual Keys 0 - Base
virtualKeyBase[0] = vk_numpad1;
virtualKeyBase[1] = vk_numpad2;
for(i = 0;i<array_length_1d(virtualKeyBase);i++)
{
virtual_key_add(64*i+64,304,48,48,virtualKeyBase);
}
//Virtual Keys 1 - Units
virtualKey[0] = vk_numpad0;
virtualKey[1] = ord("A");
virtualKey[2] = ord("S");
virtualKey[3] = ord("D");
virtualKey[4] = ord("F");
virtualKey[5] = ord("G");
for(i = 0;i<array_length_1d(virtualKey);i++)
{
virtual_key_add(64*i+64,304,48,48,virtualKey);
}
//Virtual Keys 2 - Support
virtualKeySupport[0] = vk_numpad0;
virtualKeySupport[1] = ord("Q");
virtualKeySupport[2] = ord("E");
virtualKeySupport[3] = ord("R");
for(i = 0;i<array_length_1d(virtualKeySupport);i++)
{
virtual_key_add(64*i+64,304,48,48,virtualKeySupport);
}
Step event:
Code:
if(keyboard_check_released(vk_numpad0)) and (!global.layer = 0)
{
global.layer = 0;
show_debug_message(global.layer);
}
else if(keyboard_check_released(vk_numpad1)) and (global.layer = 0)
{
global.layer = 1;
show_debug_message(global.layer);
}
else if(keyboard_check_released(vk_numpad2)) and (global.layer = 0)
{
global.layer = 2;
show_debug_message(global.layer);
}
Code:
draw_self();
draw_set_halign(fa_center);
draw_set_valign(fa_center);
draw_sprite(spr_guiBackground,0,0,297);
draw_set_color(c_white);
draw_set_font(fa_pixelHead);
draw_text(28,320,'$'+string(money));
if(global.layer = 0)
{
for(i = 0;i<array_length_1d(guiBase);i++)
{
draw_sprite(guiBase,0,64*i+64,304);
}
}
else if(global.layer = 1)
{
for(i = 0;i<array_length_1d(guiUnit);i++)
{
draw_sprite(guiUnit,0,64*i+64,304);
}
}
else if(global.layer = 2)
{
for(i = 0;i<array_length_1d(guiSupport);i++)
{
draw_sprite(guiSupport,0,64*i+64,304);
}
}