Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate GamesClient's popups

For some reasons, we had the terrible idea to have an application with a fixed landscape orientation and one "screen" is in portrait. Since we are using libgdx, we only rotate all the drawing part for that screen and we are also able to rotate the Ads:

adView.setRotation(-90.0f);
adView.setTranslationX(adView.getWidth() / 2 - adView.getHeight() / 2);

We are now integrating the Google Play Game Services but the popups are not displayed in the correct direction (ie. they are displayed in landscape). And I don't know how to rotate them.

mGamesClient = new GamesClient.Builder(getContext(), this, this)
                .setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
                .setScopes(mScopes)
                .create();

I know there is a setView method available, but I don't know how to create a view that the GamesClient could use.

like image 402
Maxime Chéramy Avatar asked Jan 30 '26 17:01

Maxime Chéramy


1 Answers

Although not "ideal" you could probably change the orientation at run time when you go to the portrait screen and then switch back to landscape upon leaving that screen.

For that you'd use Activity#setRequestedOrientation(int) in your MainActivity (or whatever you called your AndroidApplication subclass). You'd likely want to define an interface for invoking this if you are following the normal LibGDX setup.

You should get a resize event in which you can get set up for the new orientation (you'd no longer rotate your rendering or ad).

Alternatively, you could redesign this one screen to be landscape like the rest of the app.

like image 109
nEx.Software Avatar answered Feb 02 '26 08:02

nEx.Software



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!