How do I count displaced objects with variable

Get help using Construct 2

Post » Sun May 15, 2016 11:23 am

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!
B
11
S
3
Posts: 44
Reputation: 713

Post » Mon May 16, 2016 3:51 pm

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.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824


Return to How do I....?

Who is online

Users browsing this forum: David181, jorgmaquoi, SignalOne and 22 guests