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

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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:

    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


    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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

  • 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.

  • 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?

  • 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.

    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.

  • 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.

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