0 Favourites

Best Way to Select Menu Object with Gamepad?

  • Hi,

    I'm doing some menu stuff in my game. I want the GamePad (d-pad) to be able to go up/down, left/right in a grid. It needs to highlight the one it's on and then do an action when user hits the "A" button.

    I'd like to hear some suggestions on how people have done this. I need to be able to pick the object (all objects are the same type) and reference it directly once "on it". So when the gamepad hits "A" it knows which object it's on and uses that objects instance variables to do certain things.

    Here's a capx test of what I mean... I've done it with the Mouse which is much simpler since the user selects the "button" they want, opposed to having to scroll through it. But I need to use the GamePad.

    In my real game I've started to make it work in a cludgy way by making an array of all the XY positions of the buttons then depending on where I am in the array I know which button I'm on, but I obvious can't access that button's instance variables!

    In this test I figured a way to scroll through with cycling the IIDs however this does not help me going Left or Right with the d-pad.. so maybe there's a completely different way to do it?

    any help would be greatly appreciated!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I am not a good teacher but I made a prototype which might help. If there are any questions just ask.

    You can also use arrowkeys if you don't want to bother starting up your gamepad.

    The selections sprite is the grey one btw.

  • I just updated the original post... as I figured a way to go through IIDs but it doesn't help me go left and right with the D-pad...

  • TheNormalGeek very clever! love it.. so simple.. adding 10 to the left/right arrows.. nice..

    now I just have to figure a way to do that when my column rows aren't the same length... i.e. one column has 10 buttons, the next two over have 3 buttons.

    I could maybe make an array (yuck) and store: Array[columnnumber][what_to_add]

    column1, add 10

    column2, add 4

    column3, add 4

    ???

    seems kinda cludgy.. but maybe the best way??

  • Well. you could make it so that if there is no selections with the currentselection number then you go back to what it was before you added/removed something from the variable.

  • I'm not at my pc, so I can't check your capx right now, but you may want to have a look at my menu system as it does support directional navigation using a similiar method.

    https://www.scirra.com/forum/viewtopic.php?f=148&t=103355

  • Well. you could make it so that if there is no selections with the currentselection number then you go back to what it was before you added/removed something from the variable.

    @TheNormalGeek yes! that's it... love the simplicity.. I basically just ignore input from the D-pad L/R if it's in a row without a "neighbor".

    awesome.. thanks so much!

    here's my solution.. modified from your version.

  • zatyka cool.. I just played the demo, but that's basically what I needed... and wow your CAPX is very thorough and inclusive! thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,499
DMT2005's avatar
DMT2005
Unread hot topic Locked topic
78 38,325
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
123 14,873
Zebbi's avatar
Zebbi