How do I fix this inventory display issue?

0 favourites
  • 5 posts
From the Asset Store
Template for maintaining an inventory with crafting possibilities. Completely documented in text and video.
  • Hi,

    I've run into a problem with a simple inventory system. When an item is collected it appears in the inventory's item slot, but the first slot is always filled with a sprite displaying the default animation instead of whatever the actual item is. The subsequent items display correctly, but are always one behind the currently collected item. I can't work out if it's an issue with the inventory array action I'm using or with the JSON file.

    https://drive.google.com/file/d/1FWt_LkNIcdUCUbaTrcluHZcf3tLk-C1A/view?usp=sharing

  • You are pushing to the top of the array, is that intentional? Usually you would push to the back of an array tbh. The animation logic doesn't relate to the array and the item objects themselves don't relate to the array. Better if you give the items a variable int that is their position X in the array so you can relate. Then the items that are created will have a co-ord position and you can use the animation name that you added to the array, something like set animation to array.at(self.var,0)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    Thanks for the advice. The only reason I used push front was because push back resulted in the items displaying identical animations when created in the inventory.

    I have a very limited understanding of arrays so although I can see how using the items' X array variable will work I don't know how to set it up. Could you (or someone) please upload a small example, as I find visual aids make things easier to understand?

  • Ok I chopped it down and made something that works. Probably you are overthinking arrays, you've been here a while asking for help. Just relax and think about what you are doing, arrays are easy and all the logic is there for you to use. Trial and error will not help you with getting a working crafting system, you need to have control and understand the arrays. dropbox.com/s/u27mn3dovc9b5ya/addtoinv.c3p

  • Thanks lionz, the revised version was very helpful.

    Logic isn't my strongest point and I also have chronic health issues that leave me feeling physically and mentally exhausted so it can take a while to really 'get' things sometimes. I doubt I'll ever find arrays easy, I just want to learn enough to finish my projects.

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