Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:43:19+00:00 2026-06-01T05:43:19+00:00

I’m hoping to develop a basic (at first) custom UI for a game I’m

  • 0

I’m hoping to develop a basic (at first) custom UI for a game I’m working on. It will be used for the game itself as well as the modding tools. I have looked at the Game State Management Sample, but it just gives a bunch of code with no real explanation as to why things are working. My learning style is such that I have to know the why before I can understand the how if I’m really going to understand something. This is why I would like to get a book rather than just download another code sample.

I can create the visual part of the UI object without any issue (the easy part) and I have an idea as to how I’ll use them (with event handlers) but I’m having a hard time connecting an event handler that is fired by either key press or by mouse click to a button on the screen in XNA.

Any suggestions for books or online tutorials / lectures would be great. Code samples, although appreciated, are not very helpful without an accompanying tutorial or book. On the other hand, tutorials or books without source code aren’t very useful to me either. Also, no ziggyware tutorials please. I loved them, but they are down 🙁

Edit:

An alternative approach I’ve thought of (but don’t like much) is when a menu pops up, it pauses the game (if needed) and displays the menu. Then, whenever the mouse is clicked it checks the coordinates of the mouse click and checks to see if they intersect with one of the menu items. It’s a possibility, but it seems like it’s too messy and I feel like I should be able to tap into the event handlers. In fact, I know I can because the Game State Management Sample used them, although I’m not clear how.

Link

using the tutorial here I was able to understand how to use events with custom controls in xna. I was helped most by part 3, where it talked about making buttons. I then saw it referenced a class in the Game State Management sample (InputState). I read through InputState again and the code that used it in part three and I feel like I understand it fairly well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:43:20+00:00Added an answer on June 1, 2026 at 5:43 am

    As I’ve said in the comments, you could probably broaden your search for GUIs in games in general. I’m not aware of any XNA specific books, so below is a quick overview of general ideas to take from the GSM sample (I don’t have it to hand so class names etc. might be a little off).

    See also: Making Sense of the GSM Sample on another stack exchange site, GameDev.
    See also: The documentation (MS Word) that comes with the GSM Sample.


    General Overview:

    A general approach that works well and is used by the GSM sample is concept of a stack of screens.

    A screen defines what a user can currently see, for example the options screen or help screen or gameplay screen.

    Managing the screens:

    A manager ScreenManager in the case of GSM manages what screen(s) to draw and when.
    In this way it manages the "state" of the game.

    The basic state of the game is defined by a stack of screens. When the user drills into an option/menu item it might create a new screen and push it onto the stack. When the user presses back it’ll back out.

    The key here is that you only render the top screen (the GSM actually renders more than just the top screen to support screen transitions i.e. fading a screen in etc.). Input is only processed by the top-most screen though.

    Managing input

    You have a base class that all screens inherit from – GameScreen. This defines various methods like Render and HandleInput. The ScreenManager will call Render on a few screens (probably the top one if fully transitioned and the top 2 if mid-way through), and HandleInput on only the top screen.

    The BaseScreen could have a simple implementation of handling input common to all screens, for example, when the user presses B on the controller or Esc on the keyboard it might exit the screen. You might want to instead raise an event at this point called something like BackPressed. In the GSM sample they don’t have an event for this, they just have an OnCancel virtual method and it’s in the MenuScreen abstract class, not the base class. It would be up to deriving screen classes to handle this how they want, either by defaulting to exiting the current screen, or by doing something else (maybe pausing the game for example).

    The MenuScreen is a fairly good example of a more complicated basic screen, allowing the user to select items (that could raise an ItemSelected event, or call an OnItemSelected virtual method). They use a small class called MenuItem to manage individual menu items. The screen manages handling input (in the HandleInput event) to catch DPad/arrow key presses etc. to handle selecting different items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.