LibGDX iOS game not getting input

I am currently working on porting my LibGDX game to iOS using roboVM. Everything works, except that I ran into some problems in order for my bindings to work for admob and Google Play Game Services. I managed to solve the problem with Admob, but the same problem arose for GPGS, and I can not find a way around it. bindings are hooks that are associated with various iOS SDKs. I use them to serve Admob ads and interface with Google Play services.

I tried to execute Sample.java here:

Sample.java

But I have some problems for me. First of all, the didFinishLaunching () method overrides the selection, and it is never called. It should override didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions).

The main problem that I am currently facing is that the game does not accept user inputs due to the call to window.makeKeyAndVisible (). If I choose this method, everything will be fine, but I canโ€™t show ads and show Google Play services. I will see a warning that the window is not in the hierarchy of views. I was able to get around this for admist declarations only by contacting makeKeyAndVisible () before showing the ad and calling setHidden () after it was rejected in interstitial deletion. However, I do not have access to the same with Google Play services. It seems that someone else is not facing this problem. What could be the problem? I am not very good at iOS, so I donโ€™t understand what needs to happen for my application to accept input correctly.

+5
source share
1 answer

So, releasing the LibGDX game for iOS using Admob and GPGS or other bindings is a painful process, but I managed to get everything that works, and my game is now waiting for the review state. At the time of this answer, it appears that Apple rejects applications using Google Play Game services because the GPGS SDK logs the user into Safari to log in. This is unacceptable to Apple because it is a "bad user interface." In fact, when a user tries to log in, the GPGS SDK looks for a Google+ installation to log in if it cannot be found , and then the Chrome browser will open, and finally Safari if Chrome is not installed. After correctly integrating GPGS and trying to present my Apple binary, I ran into another issue related to the Google SDK not signing up. Since it looked like my application was rejected, even if I fixed this problem, I decided to cut the GPGS and use the Apple Game Center instead. However, I could still get GPGS with Admob running on my test device so that I could answer like here.

First, the samples in BlueRiverInteractive are not all that are useful for playing LibGDX. All UIWindow, UIViewController, and UIView elements that you do not need to contact. The IOSLauncher class should extend the delegate instead of the UIApplicationDelegateAdapter. If you look inside the Delegate, it will take care of configuring UIApplication, UIWindow and other iOS things for your application. When you expand it, you will be forced to implement createApplication (). This is mine, for example:

@Override protected IOSApplication createApplication() { final IOSApplicationConfiguration config = new IOSApplicationConfiguration(); config.orientationLandscape = false; config.orientationPortrait = true; config.useAccelerometer = false; config.useCompass = false; iosApplication = new IOSApplication(new SplishGame(this), config); return iosApplication; } 

Store iosApplication as a member of the field of your IOSLauncher class. Thanks to this, you can get UIWindow that you need to show interstitial announcements and leaders / achievements.

Secondly, make sure your IOSLauncher class overrides didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) instead of the didFinishLaunching method with only one parameter, otherwise it will not be called. In your didFinishLaunching method, you can create an instance of your GPGS manager class (moreover, within a second) and try to log in silently. What reminds me of another problem that I encountered when trying to integrate GPGS - make sure you use the GPGS manager object to make life easier (PlayServicesManager). There are two examples in the GPGS bindings project, and I first looked at a "hard to use" one that does not use the PlayServicesManager class. After you set up your manager object, you can call simple methods like manager.login () or manager.getLeaderboards () to accomplish what you need to do.

To initialize your manager class in the didFinishLaunching method, do the following:

  playManager = new PlayServicesManager(); playManager.setClientId(CLIENT_ID); playManager.setUserDataToRetrieve(true, false); playManager.setViewController(iosApplication.getUIViewController()); playManager.didFinishLaunching(); 

For Game Center, itโ€™s like this:

 gcManager = new GameCenterManager(iosApplication.getUIWindow(), new GameCenterListener() {...(overridden methods left blank) gcManager.login(); 

Then the code from your main project can call the necessary functions through your ActionResolver interface - or what you called your native interface. This way you will have stuff like:

 @Override public void getLeaderboards() { log.debug("Showing all leaderboards."); playManager.showLeaderboardsPicker(); } 

And everything should work.

Another thing that you apparently need to do (for GPGS only) is to copy this method to the IOSLauncher class:

 // copy-paste this to your app delegate. @Override public boolean openURL(UIApplication application, NSURL url, String sourceApplication, NSPropertyList annotation) { return GPPURLHandler.handleURL(url, sourceApplication, annotation); } 

So about this, as far as I remember. Please write if you think that something is wrong, or I forgot something important.

+3
source

Source: https://habr.com/ru/post/1208549/


All Articles