[Solved][iOS]Game return with black screen

Anything libgdx related goes here!

[Solved][iOS]Game return with black screen

Postby harry0310 » Fri Feb 08, 2013 2:13 pm

I faced some bugs and some problems while porting my game to iOS when integrating the Game Center

1. My game is on landscape mode. When I try to enter game center, it's no problem on emulator, but on my touch (with iOS 6.0), it's crashed and shows this log

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: UIApplicationInvalidInterfaceOrientation Reason: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at com.catstudio.littlesoldiers.Application.Main (System.String[] args) [0x00000] in /Users/cat/Desktop/workspace/LittleCommander-ios/Main.cs:107

2. On emulator when I try to hit 'done' button of GKAchievementView, I write the code as below, the game center view dismissed but the screen is totally black. The game is not crash because I still hear BGM.
Code: Select all
         if (lp.Authenticated) {
            Console.WriteLine ("player authed 1111" + lp);

            UIViewController controller = UIApplication.SharedApplication.Windows [0].RootViewController;
            GKAchievementViewController center = new GKAchievementViewController ();
            center.DidFinish += delegate {
               controller.DismissModalViewControllerAnimated(true);
            };
            controller.PresentModalViewController(center,true);
         } else {
            UIApplication.SharedApplication.BeginInvokeOnMainThread (delegate {
               lp.Authenticate (delegate(NSError error) {// log errors
                  Console.WriteLine ("=====player auth========" +(error!=null?error.Code:0)+" - "+ error);
               });
            });
         }

Could someone help me, I badly need the game center function. Thank you
Last edited by harry0310 on Tue Feb 12, 2013 4:34 pm, edited 1 time in total.
harry0310
 
Posts: 19
Joined: Wed Mar 28, 2012 2:53 am

Re: Bugs & questions on ios backend

Postby mzechner » Sun Feb 10, 2013 8:21 pm

I'm not sure anyone here has integrated GameCenter yet. You might have better luck on the MonoTouch forums. Tescott may know something about this.
mzechner
Site Admin
 
Posts: 4715
Joined: Sat Jul 10, 2010 3:50 pm

Re: Bugs & questions on ios backend

Postby tescott » Sun Feb 10, 2013 8:48 pm

Sorry, I have zero experience with GameCenter.

--tim
tescott
 
Posts: 484
Joined: Tue Apr 12, 2011 2:32 am

Re: Bugs & questions on ios backend

Postby IMakeGames » Mon Feb 11, 2013 9:15 pm

I'm running into a similar (the same?) problem concerning the black screen. It seems like it's not special to GameCenter, but more general. On the Xamarin docs, I read about how to open the App Store from inside the game (http://docs.xamarin.com/ios/Guides/Plat ... o_StoreKit). There is a sample code which shows how to open a certain app (using the productId) in the App Store from within your app. I integrated the code and it also shows a black screen when I hit "cancel" to get back to my app/game. The code I'm using is:
Code: Select all
if (UIDevice.CurrentDevice.CheckSystemVersion (6,0)) {
            var spp = new StoreProductParameters(343200656);
            var productViewController = new SKStoreProductViewController ();
            // must set the Finished handler before displaying the view controller
            productViewController.Finished += (sender, err) => {
               // Apple's docs says to use this method to close the view controller
               iosa.getUIViewController().DismissViewController(true, null);
            };
            productViewController.LoadProduct (spp, (ok, err) => { // ASYNC !!!
               if (ok) {
                  iosa.getUIViewController().PresentViewController (productViewController, true, null);
               } else {
                  Console.WriteLine (" failed ");
                  if (err != null)
                     Console.WriteLine (" with error " + err);
               }
            });
         } else {
            // don't do stuff requiring iOS 6.0, use the old syntax
            // (which will take the user out of your app)
            var nsurl = new NSUrl("http://itunes.apple.com/us/app/angry-birds/id343200656?mt=8");
            UIApplication.SharedApplication.OpenUrl (nsurl);
         }

The variable "iosa" is the IOSApplication instance. On the Simulator (using 6.1), the store is opened correctly and also shows the Angry Birds app. Upon hitting "cancel", the App Store screens moves back down and disappears, but only a black screen stays.

I just found out that my app is still responsive in this state. I can still click buttons if I manage to hit one on the black screen. So "only" the drawing is messed up by this...

Maybe the app loses the OpenGL context? This seems to be an iOS 6.0+ mechanic, so maybe this is not supported by LibGDX yet?
Platformer for iOS, Android, Windows, Mac and Linux: Rico - A Tale Of Two Brothers
IMakeGames
 
Posts: 41
Joined: Thu Dec 01, 2011 11:48 pm

Re: Bugs & questions on ios backend

Postby tescott » Mon Feb 11, 2013 10:36 pm

I've got some voodoo you could try. This seemed to clear up my problems with getting a black screen. Add the following to IOSGraphics.java:

Code: Select all
   @Override
   protected void CreateFrameBuffer()
   {
      if (!frameBufferCreated)
      {
         super.CreateFrameBuffer();
         frameBufferCreated = true;
      }
      Gdx.app.debug(tag,"CreateFrameBuffer");
   }
   
   @Override
   protected void DestroyFrameBuffer()
   {
      Gdx.app.debug(tag,"DestroyFrameBuffer");
   }


You will also need to create a boolean frameBufferCreated in the same class.

Your other option is to disable the multi-threading capabilities of your app via the info.plist settings. I believe that's the approach that Noblemaster took.

--tim
tescott
 
Posts: 484
Joined: Tue Apr 12, 2011 2:32 am

Re: Bugs & questions on ios backend

Postby harry0310 » Tue Feb 12, 2013 4:33 pm

Problem solved! :D You did me a big favor! Thank you very much! I have been stuck here for almost 1 week.
harry0310
 
Posts: 19
Joined: Wed Mar 28, 2012 2:53 am

Re: Bugs & questions on ios backend

Postby IMakeGames » Tue Feb 12, 2013 4:44 pm

harry0310 wrote:Problem solved! :D You did me a big favor! Thank you very much! I have been stuck here for almost 1 week.

What did you do to solve it? The changes to IOSGraphics? Or the info.plist change?
Will the "voodoo" become part of official source code?
Platformer for iOS, Android, Windows, Mac and Linux: Rico - A Tale Of Two Brothers
IMakeGames
 
Posts: 41
Joined: Thu Dec 01, 2011 11:48 pm

Re: [Solved][iOS]Game return with black screen

Postby harry0310 » Tue Feb 12, 2013 5:25 pm

Just changed the IOSGraphics
harry0310
 
Posts: 19
Joined: Wed Mar 28, 2012 2:53 am

Re: [Solved][iOS]Game return with black screen

Postby mzechner » Tue Feb 12, 2013 10:13 pm

I would love to add this to core, Tescott even send us a pull request. However, team Gemserk said it's not how to solve the issue. I'm not sure what's the correct way to do it. If somebody wants to help, i'd be super happy!
mzechner
Site Admin
 
Posts: 4715
Joined: Sat Jul 10, 2010 3:50 pm

Re: [Solved][iOS]Game return with black screen

Postby pranav008 » Sat Feb 16, 2013 10:48 am

I tried to change IosGraphics.java but the change is not reflected in monotouch project.

I did the following :

1. extracted nightly.zip and opened gdx-backend-iosmonotouch-sources
2. From there I changed IosGraphicsjava.
3. I then made a new jar file gdx-backend-iosmonotouch.jar and replaced it with original jar file in the nightly folder.
4. Compressed all the files from nightly folder in .zip file. Used this .zip file to make a new project throuch gdx-setup-ui.jar.
I tried to open my project in monotouch and from com-gdx-backendios.dll i found that the changes in IosGraphics are not being reflected.

Am i missing something ?? Or is there any other better way to do it????

I even tried to open gdx-backend-iosmonotouch-sources.jar with winrar and edit IosGraphics.java and save it.
even this didn`t work.
pranav008
 
Posts: 69
Joined: Fri Feb 08, 2013 6:23 am

Next

Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], hkahleong, Lomelin and 7 guests