Possible to Move Objects Between Layouts

Get help using Construct 2

Post » Wed Oct 30, 2013 7:26 am

Is it possible to move objects between layouts? I want to be able to loot my monster on the world layout and then have the object appear in the inventory layout. I don't want to set the object to global, because then it shows up on my global layout even after the item has been "looted."

Any ideas?
B
9
Posts: 12
Reputation: 351

Post » Wed Oct 30, 2013 9:45 pm

Here's what I've come up with so far:

On click Object,(Looting it)->Set GlobalVariable=1
                            -> Destroy Object

And on my inventory layout:

Every tick
GlobalVariable=/=0 ->Spawn Object at Inventory Slot
                   ->Set GlobalVariable=0

The only problem with this is that it populates all my inventory slots with the same item. I need to figure out how to select an empty Inventory slot (instance variable maybe?) and then only create it in that specific empty slot, and not every empty slot.

Thoughts?
B
9
Posts: 12
Reputation: 351

Post » Thu Oct 31, 2013 2:02 am

[QUOTE=fuzzball45] Here's what I've come up with so far:

On click Object,(Looting it)->Set GlobalVariable=1
                            -> Destroy Object

And on my inventory layout:

Every tick
GlobalVariable=/=0 ->Spawn Object at Inventory Slot
                   ->Set GlobalVariable=0

The only problem with this is that it populates all my inventory slots with the same item. I need to figure out how to select an empty Inventory slot (instance variable maybe?) and then only create it in that specific empty slot, and not every empty slot.

Thoughts?[/QUOTE]

Yeah, I would use an instance boolean variable (i.e isEmpty). Then when you're ready to add item to inventory slot, loop through each slot using "For Each" and if isEmpty = true, add item to slot. Then you must use "Stop Loop" so that item is only added at the first empty slot the loop encounters.

For example:

[System]For each Slot
-> [Slot] Is isEmpty -> [System] Create Object at Slot
                      -> [Slot] Set isEmpty to False
                      -> [System] Stop loop



Also, other ways you can achieve this:

1) You can use an inventory array that's set to global. Every time you loot in the world layout, you can just update the array. Then on inventory layout load, you can have the layout retrieve values from the inventory array.

2) Use global inventory object but when you want it hidden in the world layout, just offset its position outside the canvas (i.e -100px, -100px).syncdot2013-10-31 02:04:31
B
10
S
3
G
1
Posts: 11
Reputation: 1,554

Post » Sat Nov 02, 2013 6:34 am

Let me just say you are a genius. I don't know why I wasn't thinking about using a for each loop every time i created a new item. Thank you so much!
B
9
Posts: 12
Reputation: 351


Return to How do I....?

Who is online

Users browsing this forum: LaDestitute, sean080 and 23 guests