Closed tomfisher closed 9 years ago
FYI: I like this, and I'll merge it soon, but I want to be sure that the "normal" use case is as simple as it is today. So I need to do a bit of tidying, which I should have time for soon.
I am very glad to hear you will merge it soon since the project I am working on is highly dependent on PlayN. The second submission could be one of simplest solutions and just needs a few lines of integration code:
public class Main {
public static class GameApplicationAdaptor extends RoboApplicationAdaptor{
@Override protected Game createWith(Config config) {
config.iPadLikePhone = true;
return new Game.Default(30) {@Override public void init() {}};
}
}
public static void main(String[] args) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(args, null, GameApplicationAdaptor.class);
pool.close();
}
}
Expose PlayN as a normal iOS view controller and bind the game lifecycle with it. This also makes both integration and customisation easier, which always happens in a view controller.
RoboGameController could be more accurate name than RoboRootViewController which may or may not be a root view controller now in the current context and sounds a little bit confusion. I did not change that for the sake of patch reviewing.
I'v tested with my application and also wrote a simple application demonstrating how to use PlayN as a standalone application or an embedded application. Probably it should be included in the play-smaples project.
package tripleplay.demo;
import org.robovm.apple.foundation.NSArray; import org.robovm.apple.foundation.NSAutoreleasePool; import org.robovm.apple.uikit.UIApplication; import org.robovm.apple.uikit.UIApplicationDelegateAdapter; import org.robovm.apple.uikit.UIApplicationLaunchOptions; import org.robovm.apple.uikit.UIBarButtonItem; import org.robovm.apple.uikit.UIBarButtonItem.OnClickListener; import org.robovm.apple.uikit.UIBarButtonSystemItem; import org.robovm.apple.uikit.UIButton; import org.robovm.apple.uikit.UIControl; import org.robovm.apple.uikit.UIControl.OnTouchUpInsideListener; import org.robovm.apple.uikit.UIControlState; import org.robovm.apple.uikit.UIEvent; import org.robovm.apple.uikit.UINavigationController; import org.robovm.apple.uikit.UIScreen; import org.robovm.apple.uikit.UIViewController; import org.robovm.apple.uikit.UIWindow;
import playn.core.CanvasImage; import playn.core.Color; import playn.core.Game; import playn.core.ImageLayer; import playn.core.PlayN; import playn.core.Pointer; import playn.core.Pointer.Event; import playn.robovm.RoboRootViewController; import tripleplay.demo.Main.GameDemo.Exit;
public class Main {
}