Possible to Move Objects Between Layouts

0 favourites
  • 4 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • 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?

  • 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?

  • 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?

    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).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

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