How do I count displaced objects with variable

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • So I have made an inventory slot, and the idea is of the following:

    Got only one inventory slot with 10 apples stacked in it, something like an apple and at the bottom left corner it says how much apples i got in this slot right now, whenever I displace the apple with drag and drop function beyond the inventory slot it should reduce the current number of apples in the slot.

    The problem, I've created 10 instances of apples, created global variable with value 10 and made it the way that whenever i move an apple beyond the slot it will subtract 1 from the global variable. However as it stands now i had to use "Is overlaping" for the apple that overlaps the inventory slot, whenever I take the apple away it keeps subtracting. What I want is to reduce the global variable by one whenever the apple leaves the inventory slot.

    Any suggestions? By the way, maybe someone can suggest any method to take care of these apples in more comfortable manner, as in case of 100 apples will be hard to manage them all.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need a data structure behind that to help manage the global state. Like JSON, or an array, or something. Then you can just load your inventory UI from the global state and automatically update the inventory based on that state.

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