How do I scroll through weapons?

0 favourites
  • 5 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I have an array that has the weapons in it and every time you scroll down it chooses the weapon below the current one and scrolling up chooses the one above it, but when I get to the last entry in the list instead of scrolling down going back up to the top it sets the weapon value to zero and stops. If I scroll up at the topmost weapon it sets the value to zero, but scrolling again will set it back to the bottom most gun. How do I effectively set up this system?

  • If you don't have fixed positions for the weapons like 0=fist 1=pistol... you could set the array x to 0 and when you get new weapon you can use push back on the array.

    When your weapon selection is greater or equal the array width (note that array width will count also the first 0) set selection to 0 and when your selection is less than 0 set selection to array width-1.

  • See the guns are always static though, the first gun will always be the pistol the second will always be an ice gun, etc, how do I make this work?

  • One option I think should works is to name the weapons as "0_Pistol", "1_Ice gun" and every time you pick a new weapon you could push it back and sort the array.

    Another option is to have fixed positions in the array and run loop to next none 0 slot.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have the second setup you described at the moment, but I must have done it wrong because it doesn't work properly. Can you give a quick screencap of the loop setup?

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