How do I This System Inventory [SOLVED]

Get help using Construct 2

Post » Tue Jul 04, 2017 11:00 am

@willmonteirofx

How about this solution? :

https://www.dropbox.com/s/vl30jbms1ucpf ... .capx?dl=0

Arrow keys to move the avatar, left click on an inventory item to remove it.

I just use one item object with the different types set to separate animations, and one inventory object with the same animations plus "none". I then lay out multiple inventory instances.
At the start I assign each inventory slot with a number (instance variable "no"), based upon its position; I'm using the distance expression to automate this, but you can assign manually if needed.

Each time the avatar collides with an object the code searches for the inventory instance with the lowest "no" value and an animation of "none" and matches the animation to the object.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Tue Jul 04, 2017 11:55 am

This is for sure, the most practical and simple inventory, good job! But I'm looking for a more complete and controllable inventory. Like that...

1 - When colliding, set the item to the next empty slot.
2 - Clicking on the slot item, it sets the tick position every tick to the Mouse.
3 - When clicking on the floor with the item, the item spawn on the floor, in the same position as the mouse.

And then the collision cycle returns...

I'm having trouble organizing this little library of items and the question of positions too. There are many variables, I can not think correctly.
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Tue Jul 04, 2017 1:50 pm

@willmonteirofx

Download the capx link again. Items were already being added to the first available slot, but I've also updated it as follows:

Clicking on an inventory item selects it and adds it to your mouse.
You can click again in the inventory to return an item to any slot. If there is already an item in that slot then it will swap the item.
Click outside the inventory to add the object back to the floor.
The text shows the currently selected item.

Only one global variable and one instance variable! ;p
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Tue Jul 04, 2017 7:47 pm

Huh! i'm tryng to to this, i'm back soon... '3'
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Thu Jul 06, 2017 9:14 am

Hello I'm back... good news! xD

I implemented it and it is almost working fine ... due to the parallax of my "HUD" layer when I click on the item that is in the inventory, it is simply behind the slots, because it spawns in the "Principal" Layer. Ideally he should stay ahead. But if I make him spawn in "HUD" he'll just disappear before I even get him to drop.

Image

Image

EVENTS

Image

Any idea how to solve it?
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Thu Jul 06, 2017 10:31 am

Hi @willmonteirofx,

I've updated the capx again, adding in scrolling for the object layer and locking the hud:

https://www.dropbox.com/s/vl30jbms1ucpf ... .capx?dl=0

Instead of creating and destroying the picked object I just set it visible and invisible as needed.
To keep the picked object on the mouse I set its position to mouse.X("picked"), mouse.Y("picked"), which means that it follows the mouse's position relative to the "picked" layer.
I added now run the check to avoid spawning objects on the inventory against the inventoryFrame object rather than the inventory objects.
Lastly, I swapped the names of the animations to their respective colour, rather than "one","two" etc, so that the picked text is less confusing.
Notice that the both the "picked" and "inventory" layers have parallax 0,0.
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Thu Jul 06, 2017 1:03 pm

Another idea would be the following : instead of moving the position of the object, each slot would have different animation which adapts when you collide an object. Each object has an ID. If you collide an object, this one is destroyed. On destroyed, you figure out how to pick the ID of this very object.
Then you launch a for loop which looks for the first slot being empty. Once it's found, you set the animation you wish to the slot depending on the ID of the collided object.
However, if you do so, all empty slot will be filled with te new object. To avoid this issue, you can add a test in the "for loop" to stop at the moment it reaches the first empty slot. For instance a boolean "isSearching" which is true until it finds an empty slot.
B
6
S
1
Posts: 29
Reputation: 408

Post » Sun Jul 09, 2017 1:34 pm

Hello Again!

First of all thank you! The inventory system code was not so clear to me, but it worked perfectly, in time I know I'll understand. I thank you for your patience, I apologize for any inconvenience and I will be more than happy to help.

Image

I made a simple build of the prototype that already has ready, who wants to check how it was, feel free to test the link below. If there is a bug, feel free to report it too, I'll be happy to correct it.

Link: https://imersastudios.itch.io/survive-it

OBS: Apologies for my English, I know it is not very good. But with everything it gave you to understand xD

Thank you again!
B
15
S
4
G
1
Posts: 36
Reputation: 1,455

Post » Sun Jul 09, 2017 2:48 pm

@willmonteirofx Glad to be able to help out - let me know if you need any further explanation. The prototype is looking nice btw :)
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Sun Jul 09, 2017 3:41 pm

stop apologizing for everything and keep being nice ;) bravo for your inventory !
B
6
S
1
Posts: 29
Reputation: 408

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests