1
\$\begingroup\$

I have implemented to my game a simple leaderboard and submit score pages, which are pages in XAML. I used PreferredBackBufferHeight/Width to set the buffer to be equaly on all devices, whether their screen size is 5 inch, 4.7 or whatever size. Though I thought the problem was solved, now, when I was testing my game on emulator for bigger devices, I encountered a problem when returning back to game page from the xaml page. Let me show you some pics, and you will understand what I am talking about:

Testing on Emulator 4.7 inch:

1) Before entering the leaderboard xaml page (everything normal):enter image description here

2) After exiting from xaml leaderboard page: enter image description here

Even if I tried to put the PreferredBackBufferHeight/Width in the function that I call to exit from the leaderboard page, it didn't change anything... :

private void NavigateBackToMain()
    {
        var app = App.Current as App;

        if (app.GamePage == null) app.GamePage = new GamePage(string.Empty);
        Game1.statics.graphics.SupportedOrientations = Microsoft.Xna.Framework.DisplayOrientation.LandscapeRight | Microsoft.Xna.Framework.DisplayOrientation.LandscapeLeft;
        Game1.statics.graphics.PreferredBackBufferHeight = Constants.PrefferedBufferHeight;
        Game1.statics.graphics.PreferredBackBufferWidth = Constants.PrefferedBufferWidth;

        Window.Current.Content = app.GamePage;
    }

What can I do about my problem?

\$\endgroup\$
3
  • \$\begingroup\$ i do understand your problem, however i don't think inches make a difference at all. its about screen resolution (pixels). also, did you try calling graphics.ApplyChanges() ? \$\endgroup\$
    – dimitris93
    Commented Mar 11, 2015 at 13:54
  • \$\begingroup\$ Lol ... I have started trying to resize somehow the xaml page, but Thanks! It worked after adding grahics.ApplyChanges(). Thank you very much! :D By the way, I think you heard about the problem that freezes the game if you tap fast on the screen in Monogame, do you know a fix for this? \$\endgroup\$
    – Edvin
    Commented Mar 11, 2015 at 14:09
  • \$\begingroup\$ I haven't heard it but for this type of problems you are better of asking community.monogame.net here. monogame developers usually answer these \$\endgroup\$
    – dimitris93
    Commented Mar 11, 2015 at 14:32

1 Answer 1

1
\$\begingroup\$

I think you solved your problem already, but for any future visitors to the site here it is as well.

The problem that you were having was that you never called Graphics.ApplyChanges() after you changed your graphics settings. This resulted in the screen not actually being updated, and the smaller screen after exiting is due to an odd orientation bug.

Here's what your code should look like:

private void NavigateBackToMain()
{
    ....
    Game1.statics.graphics.SupportedOrientations = Microsoft.Xna.Framework.DisplayOrientation.LandscapeRight | Microsoft.Xna.Framework.DisplayOrientation.LandscapeLeft;
    Game1.statics.graphics.PreferredBackBufferHeight = Constants.PrefferedBufferHeight;
    Game1.statics.graphics.PreferredBackBufferWidth = Constants.PrefferedBufferWidth;

    Game1.statics.graphics.ApplyChanges();
    ....
}
\$\endgroup\$
3
  • \$\begingroup\$ Yeah... But this only works if you are targeting Windows Phone 8.1 projects, because I am currently working on a Windows Phone 8 game, and if I use this method, it does not work... \$\endgroup\$
    – Edvin
    Commented Jul 25, 2015 at 14:15
  • \$\begingroup\$ @Edvin I believe with the most current version of Monogame this issue is fixed. I suggest that you try it out and then add another comment. \$\endgroup\$
    – Pip
    Commented Jul 27, 2015 at 1:20
  • \$\begingroup\$ Nope, it is not working. In my case, I used that code in the main Game1 method, so I do not need to scale all the content in different way, but it is not working as if you target windows phone 8.1 ... \$\endgroup\$
    – Edvin
    Commented Jul 27, 2015 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .