Skip to content

Commit f38b756

Browse files
committed
[ShipGame]Dynamically set FullScreen for mobiles.
1 parent 0298367 commit f38b756

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

ShipGame/ShipGame.Core/ShipGame.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,23 @@ public ShipGameGame()
3838
soundManager = new SoundManager();
3939
game = new GameManager(soundManager);
4040

41+
// Runtime platform detection - works because Core project is shared
4142
// On desktop, use the preferred resolution from GameOptions
42-
// On mobile/consoles, these values will be overridden by the device's native resolution
43-
#if WINDOWS || WINDOWS_UAP || DESKTOPGL
44-
graphics.PreferredBackBufferWidth = GameOptions.ScreenWidth;
45-
graphics.PreferredBackBufferHeight = GameOptions.ScreenHeight;
46-
#else
47-
// On mobile platforms, use native resolution
48-
graphics.IsFullScreen = true;
49-
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
50-
#endif
43+
// On mobile platforms, use native resolution in fullscreen
44+
bool isMobile = OperatingSystem.IsAndroid() || OperatingSystem.IsIOS();
45+
46+
if (isMobile)
47+
{
48+
// Mobile: Use native resolution in fullscreen landscape mode
49+
graphics.IsFullScreen = true;
50+
graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
51+
}
52+
else
53+
{
54+
// Desktop: Use preferred resolution from GameOptions
55+
graphics.PreferredBackBufferWidth = GameOptions.ScreenWidth;
56+
graphics.PreferredBackBufferHeight = GameOptions.ScreenHeight;
57+
}
5158

5259
IsFixedTimeStep = renderVsync;
5360
graphics.SynchronizeWithVerticalRetrace = renderVsync;

0 commit comments

Comments
 (0)