Hello, I am currently working on a game that involves an inventory and crafting window. These two menus are separate from each other and will never be opened at the same time. I have come into a problem I have no idea how to fix. The code following is how I detect if you press a button to open your inventory or crafting window. This is the code to open my crafting menu. "e" checks for the inventory being opened, so it will close out of the crafting menu.
I have almost the exact same code in my inventory, with a view differnt methods/variables. The inventory opening works perfectly fine, however the crafting menu will not open up, UNLESS I comment out the "key = Greenfoot.getKey();" line in the inventory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | private void checkKey() { key = Greenfoot.getKey(); if ( "e" .equals(key)) { if (!open) { open = !open; CloseCrafting(); } else { open = !open; CloseCrafting(); } } if ( "c" .equals(key)) { if (!open) { open = !open; OpenCrafting(); } else { open = !open; CloseCrafting(); } } } |