【发布时间】:2015-08-18 23:56:17
【问题描述】:
所以我想为我的游戏创建一个 winforms GUI...但我似乎找不到经过测试可与 Monogame 一起使用的 GUI 库。这就是为什么我有另一个计划:
- 创建一个 WinForms 项目作为我的游戏的启动。
- 然后,当用户在该项目的主窗体中单击“开始游戏”时,winforms 项目应查找我的 Monogame 项目可执行文件并启动它,然后该窗体应关闭。
- 但是,我想将参数从 WinForms exe 传递给 Monogame exe。这样做的目的是在一定程度上阻止用户通过 Monogame exe 启动游戏,而改用 Winforms“Starter”。这导致第 4 步。
- 如果没有参数传递给 Monogame 项目,它应该关闭。
所以我应该像在控制台应用程序中那样,将一个字符串数组传递给 Monogame 应用程序的主空白,如下所示:
using System;
namespace myGame
{
#if WINDOWS || LINUX
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
using (var game = new Game1())
game.Run();
if (args[0] != "startFromWinForms")
{
// Find a way to close or
// on the other hand I think
// it will throw an exception??
}
}
}
#endif
}
你会怎么做?你推荐什么方法?解释代码示例/想法也很棒!
【问题讨论】:
标签: c# .net winforms user-interface monogame