Search in sources :

Example 1 with UIWindow

use of org.robovm.apple.uikit.UIWindow in project libgdx by libgdx.

the class IOSApplication method didFinishLaunching.

final boolean didFinishLaunching(UIApplication uiApp, UIApplicationLaunchOptions options) {
    setApplicationLogger(new IOSApplicationLogger());
    Gdx.app = this;
    this.uiApp = uiApp;
    // enable or disable screen dimming
    UIApplication.getSharedApplication().setIdleTimerDisabled(config.preventScreenDimming);
    Gdx.app.debug("IOSApplication", "iOS version: " + UIDevice.getCurrentDevice().getSystemVersion());
    // fix the scale factor if we have a retina device (NOTE: iOS screen sizes are in "points" not pixels by default!)
    Gdx.app.debug("IOSApplication", "Running in " + (Bro.IS_64BIT ? "64-bit" : "32-bit") + " mode");
    float scale = (float) (getIosVersion() >= 8 ? UIScreen.getMainScreen().getNativeScale() : UIScreen.getMainScreen().getScale());
    if (scale >= 2.0f) {
        Gdx.app.debug("IOSApplication", "scale: " + scale);
        if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad) {
            // it's an iPad!
            displayScaleFactor = config.displayScaleLargeScreenIfRetina * scale;
        } else {
            // it's an iPod or iPhone
            displayScaleFactor = config.displayScaleSmallScreenIfRetina * scale;
        }
    } else {
        // no retina screen: no scaling!
        if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Pad) {
            // it's an iPad!
            displayScaleFactor = config.displayScaleLargeScreenIfNonRetina;
        } else {
            // it's an iPod or iPhone
            displayScaleFactor = config.displayScaleSmallScreenIfNonRetina;
        }
    }
    // setup libgdx
    this.input = new IOSInput(this);
    this.graphics = new IOSGraphics(scale, this, config, input, config.useGL30);
    Gdx.gl = Gdx.gl20 = graphics.gl20;
    Gdx.gl30 = graphics.gl30;
    this.files = new IOSFiles();
    this.audio = new IOSAudio(config);
    this.net = new IOSNet(this);
    Gdx.files = this.files;
    Gdx.graphics = this.graphics;
    Gdx.audio = this.audio;
    Gdx.input = this.input;
    Gdx.net = this.net;
    this.input.setupPeripherals();
    this.uiWindow = new UIWindow(UIScreen.getMainScreen().getBounds());
    this.uiWindow.setRootViewController(this.graphics.viewController);
    this.uiWindow.makeKeyAndVisible();
    Gdx.app.debug("IOSApplication", "created");
    return true;
}
Also used : UIWindow(org.robovm.apple.uikit.UIWindow)

Example 2 with UIWindow

use of org.robovm.apple.uikit.UIWindow in project playn by threerings.

the class TestsGameRoboVM method didFinishLaunching.

@Override
public boolean didFinishLaunching(UIApplication app, UIApplicationLaunchOptions launchOpts) {
    // create a full-screen window
    CGRect bounds = UIScreen.getMainScreen().getBounds();
    UIWindow window = new UIWindow(bounds);
    // configure and register the PlayN platform; start our game
    RoboPlatform.Config config = new RoboPlatform.Config();
    config.orients = UIInterfaceOrientationMask.All;
    RoboPlatform pf = RoboPlatform.register(window, config);
    pf.run(new TestsGame());
    // make our main window visible
    window.makeKeyAndVisible();
    addStrongRef(window);
    return true;
}
Also used : TestsGame(playn.tests.core.TestsGame) CGRect(org.robovm.apple.coregraphics.CGRect) RoboPlatform(playn.robovm.RoboPlatform) UIWindow(org.robovm.apple.uikit.UIWindow)

Aggregations

UIWindow (org.robovm.apple.uikit.UIWindow)2 CGRect (org.robovm.apple.coregraphics.CGRect)1 RoboPlatform (playn.robovm.RoboPlatform)1 TestsGame (playn.tests.core.TestsGame)1