How do I swap items?

0 favourites
  • 2 posts
From the Asset Store
Full game Construct 2 capx code source to post on Google Play
  • Hello

    I Work on the equipment system in the game, on the drag and drop mechanics. What I've already managed to do is that I flip the item between the inventory slots, and when the slot is full then the item returns to its old position, now I'm working on making the item not return to the old place but swap places with the currently located item. It saves such values as the position of the raised item, its UID and the slot number from which I raised it, and I've been struggling with this for a few days now but can't find a solution. Maybe someone could help and direct me :)?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On that second block I think pickedslot should be slot.UID ? Assuming that is being used to set the item back to it.

    When you drop item onto slot you need to pick the other item already in the slot, so I would start using a variable on the slot which contains the current item UID.

    Then for this I would use a function as it's easier to open up picking again and pass through as a parameter the slot.variable I mentioned (which is the UID of the item already in it).

    In the function say pick item where UID = param, and set position to picked_slot. This moves out the old item. After this you will need to run the logic that sets the slot.variable for both slots to the item that is in it, this could be another function that you call when dropping items.

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