The current state of iOS + libGDX

Anything libgdx related goes here!

The current state of iOS + libGDX

Postby jrenner » Wed May 15, 2013 2:54 am

I have read the wiki about iOS, but I still have some questions:

1. How well does the iOS backend really work? Can every project get up and running on iOS? How about performance? I have seen some threads talking about that, how much of an issue is performance?

2. RoboVM looks promising? Is work on libGDX + RoboVM still progressing? If this has a future, I would love to throw money at it to get it going faster.

3. I've never developed for iOS. Can libGDX handle stuff like in-app purchases on iOS?
Superior Tactics - tactical spaceship battles RTS
Google Play: https://play.google.com/store/apps/deta ... r.superior
jrenner
 
Posts: 520
Joined: Sun Apr 14, 2013 5:09 am

Re: The current state of iOS + libGDX

Postby xeoshow » Wed May 15, 2013 9:10 am

Also would like to know the status of #2 ...
xeoshow
 
Posts: 305
Joined: Mon Mar 18, 2013 1:12 am

Re: The current state of iOS + libGDX

Postby mzechner » Thu May 16, 2013 3:11 pm

1) Not all of the Java runtime libraries are available on iOS, most notably java.net. For that you can use the libgdx APIs. If you rely on 3rd party libraries, they may not work. Locales are problematic as well. All of those issues are described on the Wiki. In terms of performance, there's high overhead for JNI class, so super intensive box2D games may be slower on iOS than on Android. You can test if your project works by getting a business trial of Xamarin.iOS.
2) I plan on investing some time in RoboVM as soon as i stop being so god damn busy with RL. I'm worried about performance there, but overall, it looks quite nice. Additional money will not speed things up i'm afraid.
3) You can talk to iOS APIs through C# and Java. If you want to set things up in Java, you'll need to link to the Monotouch jars that where generated via IKVM and represent stubs that will later be replaced with the original C# code by Xamarin: https://github.com/libgdx/libgdx/tree/m ... touch-jars. I'd suggest to write an interface in Java, in your main project, for say showing/hiding ads, and implement that interface in C# in your Xamarin.Studio project.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: The current state of iOS + libGDX

Postby Jemchicomac » Fri May 17, 2013 4:36 pm

Hi all!

I would like to further understand 3rd point, too.

I believe there is enough level of clarity and explanations on how to port to iOS from a java code on top of libgdx, however the point now is how to, for example, invoking Game Center o a 3rd party iOS library.

Xamarin provides tools to expose in C# any 3rd party iOS library automagically( http://blog.xamarin.com/introducing-objective-sharpie/ ) but the point is how to invoke (or ar least jump to c#) this from the main java code.

The provided clues on the previous answer are great but for me (im not a great coder :oops: ) is not enough and I need at least a code snippet with an example.

Hope somebody in the comunity can help on this, this is the last topic to being well covered to make libgdx the perfect crossplatform game development framework!

Thanks in advance
Jemchicomac
 
Posts: 26
Joined: Sun Jan 20, 2013 10:46 am
Location: Madrid, Spain

Re: The current state of iOS + libGDX

Postby mzechner » Sat May 18, 2013 10:36 am

Step 1 is to understand how to interface with platform specific code. See https://code.google.com/p/libgdx/wiki/A ... rmSpecific for an introduction.

You create an interface in your main project that you are going to implement for all platforms, in their respective platform project (e.g. desktop, android, etc.). E.g.

Code: Select all
// in the main project
public interface BroswerOpener {
   public void openUrl(String url);
}

// in the desktop project
public class DesktopBrowserOpener implement BrowserOpener {
   @Override
   public void openUrl(String url) {
      // use desktop specific classes to open the url in a browser
   }
}

// in the android project
public class AndroidBrowserOpener implements BrowserOpener {
   @Override
   public void openUrl(String) {
      // use android specific classes to open the url in a browser
   }
}

// in your GWT/html project
public class GwtBrowserOpener implements BrowserOpener {
   public void openUrl(String url) {
      // use gwt specific classes to open the url in a new tab
   }
}

// in your iOS MonoDevelop/Xamarin.Studio project (not a java project!)
// the following is C# code!
public class IOSBrowserOpener: BrowserOpener {
   public void openUrl(string url) {
      // use iOS/Monotouch specific classes to open the url in a browser
   }
}


Again, note that the iOS implementation of the interface is written in C#, and contained in the MonoTouch/Xamarin.Studio project! You have all Monotouch classes available to you there.

Your ApplicationListener should have a constructor that takes an instance of this interface, and should probably store it in a field. That listener is the same across all platforms, and is contained in your main project:

Code: Select all
public class MyApplicationListener implements ApplicationListener {
   BrowserOpener browserOpener;

   public MyApplicationListener(BrowserOpener browserOpener) {
      this.browserOpener = browserOpener;
   }

   // rest of the application listener methods, which can invoke the browser opener, or pass it on to other classes
   // of the main project.
   public void render() {
      if(Gdx.input.justTouched()) {
         browserOpener.openUrl("http://www.google.com");
      }
   }
}


Upon creation of your platform specific application (LwjglApplication, IOSApplication, AndroidApplication, GwtApplication), you instantiate the correct version of the interface, and pass it to your application listener:

Code: Select all
// in the desktop project
public static void main(String[] argv) {
   new LwjglApplication(new MyApplicationListener(new DesktopBrowserOpener()), new LwjglApplicationConfiguration());
}

// in your android project
public class MyAndroidActivity extends AndroidApplication {
   public void onCreate(Bundle bundle) {
      initialize(new MyApplicationListener(new AndroidBrowserOpener()), new AndroidApplicationConfiguration());
   }
}

// in your gwt/html project
public class MyGwtApp extends GwtApplication {
   @Override
   public GwtApplicationConfiguration getConfig () {
      return new GwtApplicationConfiguration(320, 480);
   }

   @Override
   public ApplicationListener getApplicationListener () {
      return new MyApplicationListener(new GwtBrowserOpener());
   }
}

// in your iOS project, in MonoTouch/Xamarin.Studio, this is c# code!
public class Application
{
   [Register ("AppDelegate")]
   public partial class AppDelegate : IOSApplication {
      public AppDelegate(): base(new MyApplicationListener(new IOSBrowserOpener()), new IOSApplicationConfiguration()) {
      }
   }

   static void Main (string[] args)
   {
      UIApplication.Main (args, null, "AppDelegate");
   }
}


The big take away for iOS is, that you code your iOS specific implementation of the interface in C#, within Xamarin.Studio. That gives you the most easy access to all the iOS APIs that Xamarin.Studio exposes in an easy to use way.

Note that some of the platform specific implementations may need additional, platform-specific information. On Android you may have to pass the Activity to the interface implementation, so it can send an Intent, on iOS you may have to do some magic with the application delegate to get things going. All of that information can be passed to the interface implementation upon creation. Also, if a platform-specific implementation needs to get notified about certain events (say onPause/onResume on Android), you can just do that in your platform-specific starter class.

hth
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: The current state of iOS + libGDX

Postby Jemchicomac » Sat May 18, 2013 11:30 am

Thanks a lot with this explanation!!!

At least for me this is a huge step forward on my projects.

No doubt that libGDX is the best cross-platform framework for games.
Jemchicomac
 
Posts: 26
Joined: Sun Jan 20, 2013 10:46 am
Location: Madrid, Spain

Re: The current state of iOS + libGDX

Postby mzechner » Sat May 18, 2013 11:48 am

Well, my example just gave you the general steps to do things. You'll still have to figure out how to call and integrate e.g. Game Center into your iOS project.

We are currently thinking about building extensions for both cross-platform in-app purchases and game center/google play game services. Don't hold your breath though :)
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: The current state of iOS + libGDX

Postby schmoofer » Sun May 19, 2013 4:01 pm

Sorry to piggyback on this thread, but does audio recording work on iOS? I just tried converting gdx-audio.jar and gdx-audio-natives.jar to dlls but it still doesn't work. Unless I'm supposed to be using gdx-openal.jar?
schmoofer
 
Posts: 7
Joined: Sun May 19, 2013 1:04 pm

Re: The current state of iOS + libGDX

Postby mzechner » Mon May 20, 2013 12:10 am

None of the extensions, except gdx-freetype work on iOS. It's unlikely that we add support for those in the near future.

Playing back and recording PCM samples via AudioDevice isn't supported on iOS at the moment.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: The current state of iOS + libGDX

Postby schmoofer » Mon May 20, 2013 5:07 am

Thanks, Mario. Is there any way to interface with the native recording and playback capabilities of iOS, or is it a lost cause and the only way is to learn Objective-C? I'm trying to perform voice analysis for speech therapy and have all the algorithms in Java working beautifully on Android and desktop. Am I basically screwed and will have to translate the algorithms to Objective-C or maybe even try Google's J2ObC translator?
schmoofer
 
Posts: 7
Joined: Sun May 19, 2013 1:04 pm


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest