小编use*_*407的帖子

如何使用XNA调整窗口大小

我知道这个问题之前已被问过很多次了.但是,经过一个多小时的谷歌搜索,我发现的所有解决方案基本上都是一样的.每个人都说,为了在XNA中调整窗口大小,您只需在Game1类的Initiate()方法中添加以下代码行(或这些代码行的一些细微变化):

    //A lot of people say that the ApplyChanges() call is not necessary,
    //and equally as many say that it is.
    graphics.IsFullScreen = false;
    graphics.PreferredBackBufferWidth = 800;
    graphics.PreferredBackBufferHeight = 600;
    graphics.ApplyChanges();
Run Code Online (Sandbox Code Playgroud)

这对我不起作用.代码编译并运行,但绝对没有任何变化.我一直在搜索GraphicsDevice和GraphicsDeviceManager类的文档,但我一直无法找到任何信息表明我需要做除上述之外的任何事情.

我也很确定我的显卡是足够的(ATI HD 5870),虽然看起来XNA显卡兼容性上的wiki条目还没有更新一段时间.

我在Windows 7上运行,使用上面的显卡,Visual C#2010 Express和最新版本的XNA.

所以我只是希望有人可以帮我找到搞砸的地方.我将在下面发布我的整个Game1类(我将其重命名为MainApp).如果有人想看到任何其他被调用的类,请问我会发布它们.

public class MainApp : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;

    Player player;

    public MainApp()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    protected override void Initialize()
    {
        player = new Player();

        //This does not do ANYTHING
        graphics.IsFullScreen = false; …
Run Code Online (Sandbox Code Playgroud)

c# xna resize resolution window

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

resize ×1

resolution ×1

window ×1

xna ×1