屏幕大小调整C#2010

时间:2013-11-15 14:40:28

标签: c# xna height width screen

我可能只是遗漏了一些东西但是当我尝试使用:System.Windows.Forms.Screen.PrimaryScreen.Bounds.WidthgraphicsDevice.PresentationParameters.BackBufferWidth;时,我无法使用这些内容。

我可能会遗漏在内容加载器上调用它们的东西:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

1 个答案:

答案 0 :(得分:1)

您可以使用GraphicsDeviceManager更改它。

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        graphics.PreferredBackBufferHeight = 1080;   //Height
        graphics.PreferredBackBufferWidth = 1920;  //Width
        graphics.IsFullScreen = true;    //Fullscreen On/off
        graphics.ApplyChanges();   //Execute Changes!!!IMPORTANT!!!
        //if you want use/change the PresentationParameters.BackBufferWidth, you could do it with the GraphicsDevice which could be found in the GraphicsDeviceManager Class
        graphics.GraphicsDevice.PresentationParameters.BackBufferWidth;
    }