Y
Yvalson
Guest
so I have virtual buttons that get created at the creation of the room. these are the movement buttons as well as the talk and inventory button.
I first create all the buttons but in the second frame some get deleted. that is done by the following code:
I draw them using this code:
but for some reason it doesn't work (the virtual buttons the drawing works fine)
I also wanted to know if I can check if a virtual button exists and only delete it if it exists (thats for entering the inventory because based on in which state the player is (battle or not) different virtual buttons are created.
Code:
/// draw controll keys
switch (In_Inventory)
{
case 0: {
Talk = virtual_key_add(800, 430, 128,128, ord("S"))
up = virtual_key_add(128, 420, 128, 128, vk_up)
down = virtual_key_add(128, 580, 128, 128, vk_down)
left = virtual_key_add(48, 500, 128, 128, vk_left)
right = virtual_key_add(208, 500, 128, 128, vk_right)
spell_button = virtual_key_add(960, 570, 128, 128, ord("M"))
inventory_button = virtual_key_add(1086, 570, 128, 128, ord("N"))
attack_button = virtual_key_add(1016, 430, 160, 160, vk_space)
} break;
case 1: {
inventory_button = virtual_key_add(1086, 570, 128, 128, ord("N"))
} break;
}
Code:
///Battlecheck
if(global.In_Battle || global.In_BossBattle){
if(attack_button = 0){
attack_button = virtual_key_add(1016, 430, 160, 160, vk_space)
}
if(spell_button = 0){
spell_button = virtual_key_add(960, 570, 128, 128, ord("M"))
}
if(up != 0){
virtual_key_delete(up)
}
if(down != 0){
virtual_key_delete(down)
}
if(left != 0){
virtual_key_delete(left)
}
if(right != 0){
virtual_key_delete(right)
}
if(Talk != 0){
virtual_key_delete(Talk)
}
}
else if(!global.In_Battle || !global.In_BossBattle){
if(up = 0){
up = virtual_key_add(128, 420, 128, 128, vk_up)
}
if(down = 0){
down = virtual_key_add(128, 580, 128, 128, vk_down)
}
if(left = 0){
left = virtual_key_add(48, 500, 128, 128, vk_left)
}
if(right = 0){
right = virtual_key_add(208, 500, 128, 128, vk_right)
}
if(Talk){
Talk = virtual_key_add(800, 430, 128,128, ord("S"))
}
if(attack_button != 0){
virtual_key_delete(attack_button)
}
if(spell_button != 0){
virtual_key_delete(spell_button)
}
}
Code:
if(In_Inventory == 0){
if(global.In_Battle || global.In_BossBattle){
draw_sprite(Spr_Use_Attack, 0, 1016, 430)
draw_sprite(Spr_Use_Spell, 0, 960, 570)
}
else if(!global.In_Battle || !global.In_BossBattle){
draw_sprite(Spr_Move_Up, 0, 128, 420)
draw_sprite(Spr_Move_Down, 0, 128, 580)
draw_sprite(Spr_Move_Left, 0, 48, 500)
draw_sprite(Spr_Move_Right, 0, 208, 500)
draw_sprite(Spr_Talk, 0, 800, 430)
}
draw_sprite(Spr_Use_Inventory, 0, 1086, 570)
}
I also wanted to know if I can check if a virtual button exists and only delete it if it exists (thats for entering the inventory because based on in which state the player is (battle or not) different virtual buttons are created.