I'm creating a Universal (Win 8.1 + Win Phone 8.1) app using C# / Monogame (VS 2013). I'm using MonoGame v3.4.
In my game1.cs initialization code, I set:
TouchPanel.DisplayWidth = _drawState.ScreenBounds.Width;
TouchPanel.DisplayHeight = _drawState.ScreenBounds.Height;
So that touch input is consistent to my game screen size (_drawState.ScreenBounds is a Rectangle containing the dimensions of my virtual screen size).
My game is set to support only portraint orientations: I have picked only the portrait and portrait-flipped orientations in the Package.appxmanifest files for both target (Win and WinPhone), and I have set this in the game1.cs Init method:
graphics.SupportedOrientations = DisplayOrientation.Portrait |
DisplayOrientation.PortraitDown
Testing the game on the Win 8.1 Simulator and on a real Win 8.1 tablet, I found out that after an orientation change (btw, the Simulator rotates and crops the game field, whereas the real device, as expected, keeps the portrait aspect), the TouchPanel has wrong dimensions - it resets to the actual screen dimensions, and so all my touches are off.
This only happens on the Win8.1 target - the Win Phone targets works as intended.
Any ideas?
EDIT:
Since I couldn't find what was going on, I just decided to subscribe to the size changed event and set the TouchPanel.DisplayWidth
and TouchPanel.DisplayHeight
variables:
this.Window.AllowUserResizing = true;
this.Window.ClientSizeChanged += Window_ClientSizeChanged;
The Window_ClientSizeChanged method is called on the Simulator, but not on the real device.
I tried with:
_window = Windows.UI.Core.CoreWindow.GetForCurrentThread();
_window.SizeChanged += _window_SizeChanged;
Same thing - called on the simulator, not on the device.