Hello
You can assign each item with an unique id, and make an item array. Visually make all the elements of your inventory draggable, and with the "snap to its box container" ability. Make sure you have a thumbnail for each of your elements in a library, and name them with the id assigned. That way, you can make a "for" loop to place all the pieces of elements on each container, just as your array is organized.
Good luck.
Why would he need an ID for each item? If he wants to draw all the Item icons, just do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| private static final int INVENTORY_SLOTS= 30;
private static final int INVENTORY_COLUMNS = 6;
private Item[] inventory = new Item[INVENTORY_SLOTS];
...
for(int i = 0; i < INVENTORY_SLOTS; i++){ if(item[i] == null){ continue; } int slotX = i % INVENTORY_COLUMNS; int slotY = i / INVENTORY_COLUMNS; drawImageWithSomeLibrary( items[i].getIcon(), inventoryWindowPositionX + slotX * SLOT_WIDTH, inventoryWindowPositionY + slotY * SLOT_HEIGHT ); } |