消息框和放大器;在XNA对话框(C#) [英] MessageBox & Dialogs on XNA (C#)

查看:286
本文介绍了消息框和放大器;在XNA对话框(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码作为我的XNA游戏的一部分:

I'm having the following code as part of my XNA game:

    private void gameOver()
    {
        if (!m_IsGameOver)
        {
            string message = String.Format("GAME OVER!!!{0}Your score is: {1}",
                        Environment.NewLine, GameScore);
            if (MessageBox.Show(message, "GameOver", MessageBoxButtons.OK) == DialogResult.OK)
            {
                this.Exit();
            }

            m_IsGameOver = true;
        }
    }

    private void gameWon()
    {
        string message = String.Format("You Won!!!{0}Your score is: {1}",
                    Environment.NewLine, GameScore);
        if (MessageBox.Show(message, "You Won!", MessageBoxButtons.OK) == DialogResult.OK)
        {
            this.Exit();
        }
    }       



由于某些原因,我收到以下错误:

For some reason,I received the following errors:

"The name 'MessageBox' does not exist in the current context"  
"The name 'MessageBoxButtons' does not exist in the current context"    
"The name 'DialogResult' does not exist in the current context"  



存在

我特林加上System.Windows ......但似乎这样的系统不具备窗口,在它...

I'm tring to add "System.Windows..." but it seems like that "System" does not have "windows" in it...

我怎样才能解决这个问题?

How can I solve this?

推荐答案

看来你正试图在XNA中使用的WinForms类。但是,根据文档,的WinForms不包括在XNA:如可以在的 的MessageBox 文档,没有任何的的MessageBox 方法已在XNA标志第一列中,这意味着其中没有在XNA被支撑。 (见相比之下, 文档System.Linq.Enumerable ,所有的方法都在旁边的 X 的形XNA标识它们)。

It seems that you are trying to use WinForms classes in XNA. However, according to the docs, WinForms is not included in XNA: As can be seen in the MessageBox docs, none of the MessageBox methods has the XNA logo in the first column, which means that none of them is supported in XNA. (See, for contrast, the docs on System.Linq.Enumerable, where all methods have the X-shaped XNA logo next to them).

有关在游戏中图形用户界面,各种解决方案,如这个存在;更多的链接都包含在这个 并的this~~V~~aux SO质疑并的这个MSDN论坛发帖包含链接另一个列表。

For in-game GUIs, various solutions such as this one exist; more links are included in this, this and this SO question and this MSDN forum posting contains another list of links.

这篇关于消息框和放大器;在XNA对话框(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆