Best Way to Select Menu Object with Gamepad?

Discussion and feedback on Construct 2

Post » Sun Jun 15, 2014 5:08 am

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!
You do not have the required permissions to view the files attached to this post.
Last edited by jobel on Sun Jun 15, 2014 1:41 pm, edited 2 times in total.
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180

Post » Sun Jun 15, 2014 1:21 pm

I am not a good teacher but I made a prototype which might help. If there are any questions just ask. :lol:

You can also use arrowkeys if you don't want to bother starting up your gamepad.
The selections sprite is the grey one btw.
You do not have the required permissions to view the files attached to this post.
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Post » Sun Jun 15, 2014 1:41 pm

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...
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180

Post » Sun Jun 15, 2014 1:50 pm

@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??
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180

Post » Sun Jun 15, 2014 2:17 pm

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.
(\__/)

(='.'=)

(")_(")
B
23
S
10
G
1
Posts: 74
Reputation: 3,244

Post » Sun Jun 15, 2014 2:19 pm

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
B
63
S
19
G
8
Posts: 341
Reputation: 12,130

Post » Sun Jun 15, 2014 2:28 pm

TheNormalGeek wrote: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.
You do not have the required permissions to view the files attached to this post.
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180

Post » Sun Jun 15, 2014 2:37 pm

@zatyka cool.. I just played the demo, but that's basically what I needed... and wow your CAPX is very thorough and inclusive! thanks!
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180


Return to Construct 2 General

Who is online

Users browsing this forum: lukewasthefish and 10 guests