Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Miguelino |
Right now I’m creating a game meant to be a topdown exploration 2D game, which has 2 sets of inventory systems: one for “costumes” and other for “key items”
This happens with both sets of items; to summarize:
press I key to enter the menu
enter either key items or costume items
press I key again to do a quick exit
press I key again to enter the menu and navigate to the items menu that was just closed
the items menu using the item list node has a slight delay to move the selected items
The delay lasts just a few seconds
Right now I’m using the basic ui_select with I as one of the keys that triggers this action, but before that I had the inventories pop up with 2 different keys to the same effect.
At the time, these menus are being nested in a canvas layer I called GUI, which is also the child of my player node.
for some reason this doesn’t happen when I press the ui_cancel (which at this time only reverts back to a previous page) this doesn’t happen.
here’s a snippet on how the GUI manages the menus:
func _input(event):
#determines, upon using ui_select button, what action take, between hiding or showing corresponding UIs for inventory
if Input.is_action_just_released("ui_select"):
match ui_currently_up:
"ItemMenu":
toggle_inventory_visibility(ui_currently_up)
player_movement_toggle()
which_ui_up("None")
"CostumeMenu":
toggle_inventory_visibility(ui_currently_up)
player_movement_toggle()
which_ui_up("None")
"MenuSelection":
hide_menu_selection()
player_movement_toggle()
which_ui_up("None")
"None":
show_menu_selection()
player_movement_toggle()
#determines, upon using ui_cancel, to go back from either some UI inventories or exit the entire inventory GUI altogether
if Input.is_action_just_released("ui_cancel"):
match ui_currently_up:
"ItemMenu":
toggle_inventory_visibility(ui_currently_up)
show_menu_selection()
"CostumeMenu":
toggle_inventory_visibility(ui_currently_up)
show_menu_selection()
"MenuSelection":
hide_menu_selection()
player_movement_toggle()
which_ui_up("None")
"None":
pass
func which_ui_up(uiname):
ui_currently_up = uiname
func player_movement_toggle():
get_tree().call_group("Player" , "UI_movement_toggle")
func toggle_inventory_visibility(inventory_name):
get_tree().call_group(inventory_name , "toggle_inventory_visible")
func show_menu_selection():
menu_selection.show()
which_ui_up("MenuSelection")
menu_selection_first_button.grab_focus()
func hide_menu_selection():
menu_selection.hide()
And here is a snippet of what happens when the corresponding menu is “toggled on or off”:
func toggle_inventory_visible():
if self.visible == false:
show()
itemlistpointer.grab_focus()
else:
hide()
Although this is not a game breaking bug it feels off and may damage the game experience I try to offer
I hope someone h