Thumbstick Menu for Console game

0 favourites
  • 5 posts
From the Asset Store
A well commented template with list menus and shops to use in your top-down RPGs or metroidvania games!
  • So I am making a game for OUYA and I have everything I need I just cant figure out this one thing. This has to do with a gamepad thing so no need for OUYA knowledge.

    Here is my question.

    My game has various title menus and pause screens and I want to use the left thumbstick to navigate them. When I try and use all sorts of ways(cant write them all down) I always fail. I would like it so when you enter pause/start screen you can navigate up and down between the items and when selecting the one you want you hit (A) and it loads it up. So like if you moved your mouse over it and clicked it. Does anyone know how to set up that kind of menu? I just need to know how to set it up so as I move the thumbstick it scrolls through the selections.

  • Do you mean something like this in the video for level selection?

    . this is a C2 game with gamepad which is going to Ouya.

    I'm not 100% sure what you mean.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The way I did it:

    All my menu items are instances of the same sprite (or sprite font in my case to be more precise), with an instance variable called "index". Each item has a unique value indicating in which order it should be highlighted in the menu (0 for the first item, 1 for the second one and so on).

    I create a global variable (or static local in a function) named "selected", which contain the index value of selected index. I default it to 0, so the first item is selected.

    Then, for a vertical menu, I test if the Y axis of the stick is greater than 0. But in order to not go to the next item on every click, I add an "every X second" condition, where X can vary between 0.5 and 1s, depends how sensible you want the menu to be. Then in that condition I "unselect" the currently selected item, (by finding the item which index variable matches the global). Whatever that is, a highlight effect, a color or scale change, I remove it. Then I increment the global variable and select the item with matching index. If no matching item is found, that means we reached the end of the menu, there is no more item, so we go back to the first one, we set the global variable to 0 and select again the matching item.

    For reverse selection, when stick Y is less than 0, this is a bit more tricky. Instead of incrementing the global variable, you decrement it, and when it reaches -1 (you went back past the first item) this time you must select the last item in the menu, you must find the item with the highest index value and set the global variable to this value. There are several ways to do that, the simplest is to count the number of instance of menu item and subtract 1 from it, but you have to make sure that all you items have properly numbered index starting form 0 and never skipping value (like 0-1-2-3-4 and not 0-1-2-4-6). Other methods would be to manually search the highest index with a "for each" loop and a temporary variable

    The advantage of this method over hardcoding which button follows which, it that the menu become flexible, you can add, remove and reorder items without modifying the events. Then I also use a global variable stating if the menu is vertical or horizontal layout, in which case I test for the gamepad X axis instead of Y

    It you don't use sprite font but each menu item is a different sprite instead, just put them all in a family, add the instance variable to the family use a that family in your events for selecting items

    you can see it in action in my test HERE, the menu works with keyboard, gamepad, mouse and touch. you can also press Esc or the gamepad start button while in game to bring the pause menu

  • OlivierC can I see a bit of your code to see what you mean?

  • Nevermind I have a new way of doing it.

    Thanks for your help you pointed me in the right direction.

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