How do I get my Inventory working?

Get help using Construct 2

Post » Sat Apr 23, 2016 5:06 pm

Hi Guys!

So, i started working on my Sidescrolling Adventure Game and so far working with Construct 2 is great, even though i'm still pretty much a Beginner.

The two hardest things for me will be the Inventory System and the Dialogue System. I started working on my Inventory today, looked at a Bunch of Tutorials and then decided to try it in my own way :) I'm using a Dictionary Object instead of an Array because i basically only need one Dimension of Data anyways and i kinda like the Dictionary.

The picking up works like a Charm, it's the dropping of the Objects that gives me trouble... I honestly am totally confused at the moment so i try to explain what i did so far:

SET UP

I've got three Instances of my Inventory Slot with an Instance Variable from 1 to 3. The other Variable is called ActiveObject and determines, what object is currently displayed in the Slot.

I also have two global Variables. One is called "OverlappingItem" and saves the Animation Name of the object on Screen (not in the Inventory). When my Player overlaps with the Object and presses Space, the Dictionary saves the current Variable as a new Key, or to make it more understandable, the name of the object.

The "Selected Object" Variable, puts the name of the currently highlighted Inventory Item in a Variable, so the system knows, which Item is selected and gonna be dropped.

As i said, i can add all the items in my Inventory without any problems, no matter in what order i pick them up, but i can't for the life of me figure out how to drop them from the inventory without it all going crazy. It seems to delete the key but i'm not sure how i update all the slots in the best way, so it knows where to put which key. It's kinda hard to explain but if you have any questions, let me know!

Any help would be greatly appreciated! Thank you so much!

Image

Image

Image

Image
Last edited by joelmayer on Sat Apr 23, 2016 9:21 pm, edited 1 time in total.
B
15
S
5
G
1
Posts: 85
Reputation: 1,222

Post » Sat Apr 23, 2016 6:24 pm

have a function to delete the object and recreate them or you can use array. Array is best used when data is being use as a position. I normally just use a dictionary to store data. but its the array that can position them with easy check out the scrollable inventory by katala in using a dictionary with his array.

But yeah try doing the same thing with array you might have better luck there. The dictionary is horrible at positioning any thing. I had to rewrite my inventory because i couldnt get any positioning right. Just use the dictionary as a data holder to load into array for positional.

because the array has a push pop and delete that does exactly what you want.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Sat Apr 23, 2016 9:20 pm

Thanks! :) Yeah, i guess there is no way around it. I already started rebuilding the Inventory with Arrays ;) I'll keep you guys updated how it is going :)
B
15
S
5
G
1
Posts: 85
Reputation: 1,222


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, adamebastin, Bro7hers, jatin1726, ketramtu18 and 10 guests