Microsoft XNA is a set of tools with a managed runtime environment provided by Microsoft that facilitates video game development and management. XNA attempts to free game developers from writing "repetitive boilerplate code" and to bring different aspects of game production into a single system.

Post tutorial Report content RSS feed XNA Tutorial - Showing a Message Box (Using the Guide Class)

This is a tutorial for showing a Message Box, in XNA, using the Guide class.

Posted by on - Intermediate Other

This tutorial for XNA is showing a Xbox/Windows Default Message Box.

Anyways, to start this off you need XNA. Then create a XNA game project, and then put the following in the game constructor:

public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            Components.Add(new GamerServicesComponent(this));
        }

The "Components.Add(new GamerServicesComponent(this));" allows you to access the Guide class which allows you to see if the game is in trial mode or show the message dialog that we're showing.

Now add this where you want to show you're message box:

//This below is required paste it somewhere.
protected static void GetMBResult(IAsyncResult r)
{
   int? b = Guide.EndShowMessageBox(r);
}

//Add everything below when you want to show the message box
List<string> MBOPTIONS = new List<string>();
MBOPTIONS.Add("OK");
Guide.BeginShowMessageBox("Temp", "Stuff", MBOPTIONS, 0, MessageBoxIcon.None, GetMBResult, null);

It should show the message box when the condition happens.
Thanks for reading!

Post a comment

You are not logged in, your comment will be anonymous unless you join the community. Or sign in with your social account:

Platforms
Windows, Mobile, X360
Contact
Send Message
Licence
Public Domain
Release date
Engine watch
Start tracking
Tutorial
Browse
Tutorials
Share
Related Engines
XNA
XNA Public Domain
Related Groups
Microsoft Game Studios
Microsoft Game Studios Developer & Publisher