How to have both mouse and arrows control for the main menu buttons?

0 favourites
  • 3 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • The titile is a bit mispelled since I couldn't find a better one to explain my small issue, but I'll explain in here:

    So, basically I've decided to make the main menu buttons accessible through both "mouse" and "arrows" control types.

    I've made a selector for my buttons and give it a variable called "Position" with the value "0" as default.

    As you can see in the screenshot, I've made it so everytime I'll press up arrow it will substract 1 from the value and the reverse for the down arrow. I've also set the limit so it will not go after 2 or below 0, each number representing a position for each button. So you can already tell that everything was fine until now.

    Anyways, my issue is on the cursor. Everytime I'm holding my cursor over one button (play or options) the selector is going there, as it should.

    BUT, I want it to disappear after I'm not hovering with my cursor over them anymore, but it will not, since I've made it like "Cursor is over ButtonPlay>Selector>Set Position to 1. Or well, 2 for the options button.

    I couldn't make it other way since I also have the arrows which are modifying the same value.

    I've also tried to make a second selector to have one for the mouse and one for the arrows control type, but I can't make it so they don't collide with each other.

    I feel like there is an easy fix for this and I'm sure I'm missing something, but I don't know what. So I'll be grateful for any kind of help on this thing.

  • I don't see a fix for this because it's just not intuitive. If you make the selector invisible when cursor is not over the button then it would always be invisible which means the keyboard doesn't work. I would make it keyboard or mouse here and not use both.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had to solve this problem for a project last year...

    it does get a little tricky - you have to watch if the mouse is moving or not.

    I used one button object, each with an instance variable identifying its position number.

    if the user presses a key on the keyboard (up arrow, down arrow) set a flag to start ignoring the mouse and move the Selector based on its last position. The Enter key will trigger the selected button.

    if the user moves the mouse, then stop ignoring the mouse and set the selector based on the mouse position. A mouse click (or Touch) will trigger the selected button.

    https://www.rieperts.com/games/forum/MenuSelect.capx

    EDIT: the only place it might get a tad un-intuitive is if the mouse is over a button, but then the user uses the keyboard to change the selection. If the user presses Enter, does it execute the selected button or the one the mouse is over? Or if the user very carefully presses the mouse button without moving the mouse, should the selected button get executed or the one the mouse is over?

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