[Solved]How do I make a title menu controlled by arrow keys?

Get help using Construct 2

Post » Thu May 05, 2016 11:50 pm

EDIT: Here's the .capx: https://drive.google.com/open?id=0B9cfa ... Ed4V01vWEU

I'm trying to figure out how to get the cursor to move up and down between selections on a title screen, according to user input. Here's a gif I put together from stills to explain it visually:
Image

Getting it to work with touch input was super easy. It was just:
  • Touch - On Touched NewGame
    • Go to the game
  • Touch - On Touched Quit
    • Close Browser
etc.

But I can't seem to figure out the events and actions to make the above gif possible. More than that, I want it to be so that, if the user were to select options or continue, and another menu were to show up, they'd be able to have as many options as is present in the options or continue menu, not just limited to four like the title screen.

Does anyone know how to achieve this? Many thanks in advance.
Last edited by Evdog on Sun May 08, 2016 9:45 am, edited 2 times in total.
B
16
S
5
G
4
Posts: 29
Reputation: 3,100

Post » Fri May 06, 2016 12:12 am

Here you go -

https://www.dropbox.com/s/ffwojstcimlun ... .capx?dl=0

Try to figure out sub menus based on this example, if you still have trouble ask again!
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Fri May 06, 2016 3:57 am

Thank you heaps! I've got the main menu working perfectly now, both with touch controls and keyboard.

I haven't yet tinkered around with making submenus, but I will give it a go either later today or tomorrow. I'll let you know, once I do, whether I got it sorted (in which case I'll put up a .capx for anyone who stumbles upon this thread later on) or if I still need help.
B
16
S
5
G
4
Posts: 29
Reputation: 3,100

Post » Sat May 07, 2016 5:06 am

Alright, I've tinkered around with your .capx a bit: [removed as the finished .capx is now in the original post]

I initially had a bit of trouble trying to give each menu item a unique name, but I found that if I changed the "append loopindex" action to "Set text to Array.At(loopindex,0)", I could have all the menu selection names listed in a 2-dimensional array (Y=0 for main menu, Y=1,2,3,etc. for submenus).

I was able to create unique events and actions for each individual selection, with touch controls, by using:
  • On touched "Menu"
    • Text is "(name of selection)",
      • do stuff
Though, I'm still having trouble getting keyboard controls to replicate what I've done with the Touch Input. I tried:
  • On "Return" pressed
    • MarkerPosition = (0,1,2,etc.),
      • do stuff
but then they wouldn't change for submenus.

Any ideas?
Last edited by Evdog on Sun May 08, 2016 9:44 am, edited 1 time in total.
B
16
S
5
G
4
Posts: 29
Reputation: 3,100

Post » Sat May 07, 2016 9:51 pm

Ok, the key here is that you pick the menu object by touching it, then compare the contents of that specific menu object to do something. In this case I would want to follow a similar system/logic for a keyboard press, so I don't have to remake all the actions for every menu option again separately.

The question should be - How do I pick the correct menu object On Return pressed? There are a several ways. Use your marker, which is presumably next to the relevant menu object, by:

a. Menu Object - Pick Nearest to Marker.X, Marker.Y
b. Menu Object - Compare X position equal to Marker.X
c. System - Pick by Overlapping Point - Marker.X

Now that you have the correct menu object picked, the rest should work as expected.

Here is a screenshot of how to set up the sub-eventing, since you'll want an or block in there.

Image

If you've touched to pick the menu object, the subevent doesn't matter because there is only one instance to pick from anyway. If you used keyboard, none of the menu objects are picked, so the subevent will pick the one you are interested in. Every sub event below that will only care about that one menu object that you picked.

I noticed that you used a Family to destroy all the menu objects (since if you used destroy on the object itself, it would only destroy the picked "active" menu object). Just wanted to note an alternative - there is a "Pick All" condition in System that would let you reset the picking within a subevent to properly destroy all the objects. This is mostly for the reference of people demoing C2, without access to families.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Sun May 08, 2016 9:38 am

I tried the "Menu Object - Pick Nearest to Marker.X, Marker.Y", and it worked like a dream. The family also got switched to a "Pick All", as I had not known about that prior, and that's one less thing to worry about.

I also found that the marker would not return to the top position after switching menus, so I added a
  • Menu: MenuPosition=MarkerPosition
    • Set MarkerPosition to 0
to any selection that switched between menus.

It's all working just as I had hoped. Thank you very much, oosyrag.

Capx for anyone who needs it: https://drive.google.com/open?id=0B9cfa ... Ed4V01vWEU
I've added a bunch of comments to help explain what everything does, so it shouldn't be too hard to figure things out.
B
16
S
5
G
4
Posts: 29
Reputation: 3,100


Return to How do I....?

Who is online

Users browsing this forum: asdtricky, Ashley, brunopalermo, ST314 and 28 guests