locked
Changing ScreenOrientation while runtime causes the app to appear strange RRS feed

  • Question

  • User131555 posted

    Hello, I am using the following code from https://github.com/mono/CocosSharp/issues/258 to change the display orientation of my app while runtime. " public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) {

        IGraphicsDeviceService service = (IGraphicsDeviceService)application.Game.Services.GetService(typeof(IGraphicsDeviceService));
        var xnaDeviceManager = (GraphicsDeviceManager)service;
        xnaDeviceManager.SupportedOrientations = DisplayOrientation.LandscapeLeft;
        xnaDeviceManager.ApplyChanges();
    

    " But although the screen orientation changes the .WindowSizeInPixels of the mainWindow does not change wich causes the scenes to appear strangely consumed on the screen. Is there a posibility to update the CCWindow and all its propertys to the current state of the application or am i using the wrong code to it?

    Thanks for your help in advance - Tim :)

    Sunday, September 13, 2015 7:36 PM

Answers

All replies

  • User68494 posted

    What platform is this?

    Monday, September 14, 2015 4:15 AM
  • User131555 posted

    Android

    Monday, September 14, 2015 5:38 AM
  • User68494 posted

    Can't you set this up using the Activity.

    [Activity( Label = "Tests", AlwaysRetainTaskState = true, Icon = "@drawable/Icon", Theme = "@style/Theme.NoTitleBar", ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape, LaunchMode = Android.Content.PM.LaunchMode.SingleInstance, MainLauncher = true, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden) ]

    Monday, September 14, 2015 5:43 AM
  • User131555 posted

    But if I do so the App would always be in Landscape orientation. In the game I am creating the startmenu should be in Portrait orientation while the game scene should be in Landscape orientation :)

    Monday, September 14, 2015 7:12 PM
  • User68494 posted

    Tim

    Not sure exactly what you are trying to do but maybe it is the CCSceneResolutionPolicy when setting up your game.

    Take a look at Handling Multiple Resolution in CocosSharp

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, September 15, 2015 2:37 AM
  • User131555 posted

    Thank you very much kypou1 :)

    Tuesday, September 15, 2015 6:55 PM