SOLVED - How to cycle through objects in a family with the tab key?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have a family called: "Selects".

    The "Select" family, contains several different sprite objects.

    Each object has a boolean instance variable called "select".

    At the start of the game, one of the objects is selected (its select value is true - all the others are false).

    I want to be able to hit the tab key, deselect the current object, and then select the next object in the "Selects" family.

    I know how to hit tab and I know how to get all the objects in the "Selects" family, but how do I move them all at one at time (and then cycle back around to the beginning?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's simple to do but you didn't mention how they should be ordered. The 'next' object relates to what?

  • It's simple to do but you didn't mention how they should be ordered. The 'next' object relates to what?

    lionzThat's a great question. Honestly, I don't know that the order really matters in this. I just want to let the player tab through them, one at a time and then cycle around. As long as none of them are skipped, I'm happy.

  • You could use IID which is unique identifier of each instance starting at 0. So using a global variable to compare with, you have an event that always highlights the instance where object.iid=globalvariable, the first instance at IID 0 would be selected. When you press tab you add 1 to the global variable so it moves between them. You would need one additional bit of logic where gv is higher than the number of objects so that would be something like gv = object.count - > set gv to 0, to cycle back round to the first one. Because IID is kind of creation order the selection might seem random to the player but I did ask.

  • Cycle through family member example: dropbox.com/scl/fi/n29erzi09qc0wg8ghtkw2/cycle_through_family.c3p

  • You could use IID which is unique identifier of each instance starting at 0. So using a global variable to compare with, you have an event that always highlights the instance where object.iid=globalvariable, the first instance at IID 0 would be selected. When you press tab you add 1 to the global variable so it moves between them. You would need one additional bit of logic where gv is higher than the number of objects so that would be something like gv = object.count - > set gv to 0, to cycle back round to the first one. Because IID is kind of creation order the selection might seem random to the player but I did ask.

    lionzAs always, your advice is awesome and much appreciated.

  • Cycle through family member example: dropbox.com/scl/fi/n29erzi09qc0wg8ghtkw2/cycle_through_family.c3p

    alextroThank you so much for this amazing example! That is exactly what I needed. You are the best!

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