How can I properly control the window size? I’ve tried
“graphics.PreferredBackBufferWidth = X;
graphics.PreferredBackBufferHeight = Y;”,
but the screen just gets all weird. The window appears to be square, actually, and no matter what I do, it just scales everything inside itself.
I’m using a 800x600 image as background, but the image inside the window is just all over the place.
That’s the right way. If you set the preferred back buffer size outside of your game constructor you need to call graphics.ApplyChanges for the changes to take effect.
What happens exactly? Nothing should scale automatically. Maybe share some code so we can see what you’re doing.
(I just updated it to resolve a conflict but the build server takes some time…, click on the ‘Show All Checks’/Package Windows SDK/Artifacts to get it once it’s ready)
For the next one to have any effect you must update your .xaml and replace swapchainbackgroundpanel with swapchainPanel (same as the Windows 10 template)
Woud this fix it for me? I tried changing SwapChainBackroundPanel to SwapChainPanel manually here, but it stopped working (but that’s to be expected since I have no Idea what I’m doing :v )
Oh yeah, I remember something about it being kind of a “simulated” full screen or something, because W8 apps would go fullscreen by default. Still, I though it would maybe
How exactly do I go about to do that? I mean, where do I add that code? I noticed an address there (MonoGame.Framework/Graphics/GraphicsDevice.DirectX.cs), but I can’t seem to locate that in the project
Allright! I’m on Windows 10, using MonoGame 3.6 on VS2015 :v
My project is on that hybrid Windows 8.1/Windows Phone 8.1 template.
I’m actually just studying this template, since I like to build stuff on the Windows Phone but sometimes it’s just a pain to deploy everything to the device, so I figured it’d be fun to be able to deploy on the PC too without having to mess with file linking and emulators and all.
I was following a tutorial for the good old Windows template when I came across this issue which I described at the beginning. If I tell the code to draw the screen at 800x480, it works on the phone, so I’m not super worried about it, but no matter what I do, it just won’t draw the screen correctly on the Windows Store build. That’s what I’d like to achieve.
My suggestion is to adjust your GUI/Cameras to Viewport. Even windows mobile devices have different resolutions and aspect rations.
for example this line with scale to fill the viewport
var vp = GraphicsDevice.Viewport;
spriteBatch.Draw(titleScreen, new Rectangle(0, 0, vp.Width, vp.Height), Color.White);
Think of graphics.PreferredBackBufferWidth as input for ApplyChanges(), don’t use it to get the current backbuffer dimensions, although usually it will have the same value.
You can set the window to 800x480 if you like but use the desktop project for that.
AppStore apps dont resize the window, instead they scale the backbuffer.
(also you skip the ‘Deploy’ step while you debug)
use this code in your Game() constructor, or in Initialize().
graphics.PreferredBackBufferWidth = 800;
graphics.PreferredBackBufferHeight = 600;
graphics.ApplyChanges();