XNA的窗口大小调整调用LoadContent [英] XNA Window Resize Invokes LoadContent

查看:256
本文介绍了XNA的窗口大小调整调用LoadContent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我调整我的XNA窗口,以尽可能小的分辨率(0像素高)的节目再次开始调用LoadContent这将导致我的应用程序崩溃(因为我只希望它加载内容一次)。我该怎么办,有没有一种方法,我可以调整我的窗口太多(如了setMinimumSize在Java中)停止用户。还是有另一种解决方案?

Anytime I resize my XNA Window to the smallest possible resolution (0 pixels high) the program starts invoking LoadContent again which causes my app to crash (since I only want it to load content once). What can I do, is there a way I can stop the user from resizing my window too much (such as setMinimumSize in Java). Or is there another solution?

谢谢

推荐答案

要停止用户调整的窗口太多,设定与游戏窗口相关表单上的属性的minimumSize

To stop the user resizing your window too much, set the MinimumSize property on the form associated with the game window.

将以下引用添加到您的项目:

Add the following references to your project:

System.Drawing
System.Windows.Forms

添加常数所需的最小尺寸:

Add constants for your desired minimum size:

const int MIN_SIZE_X = 300;
const int MIN_SIZE_Y = MIN_SIZE_X;

以下内容添加到您的构造函数或初始化函数。

Add the following to your constructor or Initialize function.

System.Windows.Forms.Form.FromHandle(Window.Handle).MinimumSize = new System.Drawing.Size(MIN_SIZE_X, MIN_SIZE_Y);

这篇关于XNA的窗口大小调整调用LoadContent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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