Simple Visual Inventory

  • I'm new to this and am struggling with making this inventory system work.

    In the game you can pickup items. your inventory has 4 slots and each slot can hold 1 type of item at a time and only a quantity of 1 at a time (items don't stack).

    Right now i have it to where when you drag the item over your pack the sprite is deleted and a smaller version of the item is spawned in slot 1 in the inventory. but i'm stuck on when i go to pickup another item how do i make it choose the next available slot instead of using the same one?

    I have very little knowledge with arrays so if the answer lies there i might need some extra detail.

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you're doing it more visually and simple then you can have a variable tracking the number of items, and depending on the number when you drop, place it in a specific place. So if numItems is 2 then on drop set item to slot 3. This won't work if you can pull items from the middle though so 2 is empty but 1 and 3 are filled.

    You could also use on object dropped, if not overlapping item i.e. there isn't one in the slot, then place it there. That's using the presence/collision of the actual sprite object.

    You could also have the slot as an object, with an instance variable which tracks whether an item exists. On dropped over slot, if isEmpty(variable), then place the item. But this doesn't choose next slot and rather relies on the specific slot you are choosing to drop it in.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)