Make the cursor stay on the selected objects

Hi guys, I don’t know if the title wrong as I don’t know how to describe my question, so I leave it like that.

Anyway, I want to ask a question regarding the mouse cursor selection objects like what you found in many games in console, such as PlayStation 1, etc.

What I mean is for example when the main menu selection in the game appear, we won’t see the cursor and the cursor stay on the left side of the selection menu, when we press down arrow on the console, the cursor move also, but of course I want this on the computer and not in the console. To be more detail on my question, I have made the GIF Image using Photoshop.

29772-animated-cursor.gif

As you can see in the above image, the cursor is move down from the “new game” to the “load game” and so on, the cursor will moving down when we press down the down arrow on the keyboard and when the cursor stay either on the “new game”, “load game”, “options”, or “exit” and user press enter, it will respond to where the cursor pointed to, and when it reach the “exit”, and user press down arrow, the cursor will move to the “new game”

How do I can achieve this?

Thank you very much!

Your answer will be much appreciated.

I’d do it like this:

  • Make a list of labels and add all your labels inside.
  • Make an int called “selectedIndex” that tells you which item in the lsit is selected.
  • When the user presses an arrow, you increase/decrease your selectedIndex by 1. If is < 0 you set it as list.Count -1, if it is >= list.Count, you set it as 0, to ensure wrapping.
  • You then select the label from the list at the position the selectedIndex is pointing to (list[selectedIndex]).
  • You use the position of the label and its size to determine where to place the cursor. For example X of label - 10, Y of label - 5.