Microsoft.Xna.Framework.AndroidGameWindow.SetOrientation C# (CSharp) Méthode

SetOrientation() private méthode

Updates the screen orientation. Filters out requests for unsupported orientations.
private SetOrientation ( DisplayOrientation newOrientation, bool applyGraphicsChanges ) : void
newOrientation DisplayOrientation
applyGraphicsChanges bool
Résultat void
        internal void SetOrientation(DisplayOrientation newOrientation, bool applyGraphicsChanges)
        {
            DisplayOrientation supported = GetEffectiveSupportedOrientations();

            // If the new orientation is not supported, force a supported orientation
            if ((supported & newOrientation) == 0)
            {
                if ((supported & DisplayOrientation.LandscapeLeft) != 0)
                    newOrientation = DisplayOrientation.LandscapeLeft;
                else if ((supported & DisplayOrientation.LandscapeRight) != 0)
                    newOrientation = DisplayOrientation.LandscapeRight;
                else if ((supported & DisplayOrientation.Portrait) != 0)
                    newOrientation = DisplayOrientation.Portrait;
                else if ((supported & DisplayOrientation.PortraitDown) != 0)
                    newOrientation = DisplayOrientation.PortraitDown;
            }

            DisplayOrientation oldOrientation = CurrentOrientation;

            SetDisplayOrientation(newOrientation);
            TouchPanel.DisplayOrientation = newOrientation;

            if (applyGraphicsChanges && oldOrientation != CurrentOrientation && _game.graphicsDeviceManager != null)
                _game.graphicsDeviceManager.ApplyChanges();
        }

Usage Example

Exemple #1
0
        public override void BeforeInitialize()
        {
            // TODO: Determine whether device natural orientation is Portrait or Landscape for OrientationListener
            //SurfaceOrientation currentOrient = Game.Activity.WindowManager.DefaultDisplay.Rotation;

            switch (Game.Activity.Resources.Configuration.Orientation)
            {
            case Android.Content.Res.Orientation.Portrait:
                _gameWindow.SetOrientation(DisplayOrientation.Portrait, false);
                break;

            case Android.Content.Res.Orientation.Landscape:
                _gameWindow.SetOrientation(DisplayOrientation.LandscapeLeft, false);
                break;

            default:
                _gameWindow.SetOrientation(DisplayOrientation.LandscapeLeft, false);
                break;
            }
            base.BeforeInitialize();
            _gameWindow.GameView.TouchEnabled = true;
        }
All Usage Examples Of Microsoft.Xna.Framework.AndroidGameWindow::SetOrientation