Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        public override void BeforeInitialize()
        {
            var currentOrientation = AndroidCompatibility.GetAbsoluteOrientation();

            switch (Game.Activity.Resources.Configuration.Orientation)
            {
            case Orientation.Portrait:
                this._gameWindow.SetOrientation(currentOrientation == DisplayOrientation.PortraitDown ? DisplayOrientation.PortraitDown : DisplayOrientation.Portrait, false);
                break;

            default:
                this._gameWindow.SetOrientation(currentOrientation == DisplayOrientation.LandscapeRight ? DisplayOrientation.LandscapeRight : DisplayOrientation.LandscapeLeft, false);
                break;
            }

            base.BeforeInitialize();
            _gameWindow.GameView.TouchEnabled = true;
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orientation"></param>
        public override void OnOrientationChanged(int orientation)
        {
            if (orientation == OrientationEventListener.OrientationUnknown)
            {
                return;
            }
            if (ScreenReciever.ScreenLocked)
            {
                return;
            }

            var disporientation = AndroidCompatibility.GetAbsoluteOrientation(orientation);

            AndroidGameWindow gameWindow = (AndroidGameWindow)Game.Instance.Window;

            if ((gameWindow.GetEffectiveSupportedOrientations() & disporientation) != 0 && disporientation != gameWindow.CurrentOrientation)
            {
                gameWindow.SetOrientation(disporientation, true);
            }
        }