SizeOrOrientationChanged
Introduction
Code Example
// In Game1.cs Initialize() function
// Do this *after* FlatRedBallServices.Initialize.
FlatRedBallServices.GraphicsOptions.SizeOrOrientationChanged += HandleSizeOrOrientationChanged;
// Define the HandleSizeOrOrientationChanged function which will handle this event
private static void HandleSizeOrOrientationChanged(object sender, EventArgs e)
{
int newWidth = FlatRedBallServices.GraphicsOptions.ResolutionWidth;
int newHeight = FlatRedBallServices.GraphicsOptions.ResolutionHeight;
float newAspectRatio = newWidth / (float)newHeight;
// This can be game-specific. In this case we'll say anything narrower
// than an aspect ratio of 1.0 is too narrow, and the game will pause
const float requiredAspectRatioToRun = 1.0f;
if(newAspectRatio < requiredAspectRatioToRun)
{
// Do your logic here to pause the game and show an appropriate message
}
else
{
// You can unpause the game here (if it's paused) and hide things as necessary
}
}Last updated
Was this helpful?