如何在xna中设置窗口/屏幕大小? [英] How do I set the window / screen size in xna?

查看:85
本文介绍了如何在xna中设置窗口/屏幕大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在XNA中调整窗口的大小.

How can I adjust the size of the window in XNA.

默认以800x600分辨率开始.

Default it starts in a 800x600 resolution.

推荐答案

我发现您需要设置

GraphicDevice.PreferredBackBufferHeight = height;
GraphicDevice.PreferredBackBufferWidth = width;

当您在游戏类的构造函数中执行此操作时,它会起作用,但是当您尝试在构造函数的外部进行此操作时,还需要调用

When you do this in the constructor of the game class it works, but when you try do to this outside the constructor you also need to call

GraphicsDevice.ApplyChanges();

此外,您可以使用全屏显示(调试时无法正常工作)

Furthermore to have fullscreen (which is not really working correctly while debugging) you can use

if (!GraphicsDevice.IsFullScreen)
   GraphicsDevice.ToggleFullScreen();

这篇关于如何在xna中设置窗口/屏幕大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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