禁用Windows 10重新缩放xna / monogame

时间:2017-03-17 13:42:14

标签: c# visual-studio xna resolution monogame

我遇到了monogame的问题。目前我读了这样的决议:

public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        gameState = new GameState(All_Textures, AllSpritefontTexts, oldState, oldMouse); //All textures have a key, with as return: texture, starting point, clickarea
    }

    protected override void Initialize()
    {
        base.Initialize();
        oldState = Keyboard.GetState();
        oldMouse = Mouse.GetState();
        IsMouseVisible = true; //You can see the cursor
        //graphics.IsFullScreen = true;                                                                //DISABLED FOR DEVELOPING REASONS
        graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; //Set xna resolution height to curr screen resolution
        graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;   //Set xna resolution width to curr screen resolution
        graphics.ApplyChanges();
    }

有了这个,我继续研究我的项目,最近开始在其他计算机上测试我的游戏。许多计算机都有一个放大窗10,如图中所示。 image

这导致我的monogame图像和spritefonts错位并相互重叠,更不用说我生成的hitbox了。我的问题是:'如何在monogame中以编程方式禁用此放大?'

如果您需要更多代码才能回答我的问题,我的整个申请都会在此处找到https://github.com/FireStormHR/SeriousGaming

1 个答案:

答案 0 :(得分:0)

问题是您尝试将分辨率设置为屏幕大小,而不是视口大小。如果默认渲染目标的分辨率大于视口,则无法正确绘制。视口不能大于屏幕。 使用GraphicsDevice.Viewport.Width和GraphicsDevice.Viewport.Height获取所需的结果。