2017-03-17 75 views
0

我遇到了monogame问题。目前,我看像这样的解决方案:我继续在我的项目上工作禁用Windows 10重新缩放xna/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被放错地方并且相互重叠,更不用说我生成的hitboxes了。我的问题是:'如何在monogame中以编程方式禁用此放大倍数?'

如果您需要更多的代码,看看之前你能回答我的问题,我的整个应用程序可以在这里找到https://github.com/FireStormHR/SeriousGaming

回答

0

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