XNA Window Resize Invokes LoadContent

蹲街弑〆低调 提交于 2019-12-22 18:33:03

问题


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?

Thanks,


回答1:


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);


来源:https://stackoverflow.com/questions/3705579/xna-window-resize-invokes-loadcontent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!