/** * Returns the {@link Log} service. */ public static Log log() { return platform.log(); }
/** * Returns the {@link Graphics} service. */ public static Graphics graphics() { return platform.graphics(); }
/** * Returns the {@link Assets} service. */ public static Assets assets() { return platform.assets(); }
if (plat.input().hasTouch()) { plat.input().touchEvents.connect(new Slot<Touch.Event[]>() { private int active = -1; @Override public void onEmit (Touch.Event[] events) { else if (plat.input().hasMouse()) { plat.input().mouseEvents.connect(new Slot<Mouse.Event>() { private boolean dragging; @Override public void onEmit (Mouse.Event event) { else plat.log().warn("Platform has neither mouse nor touch events?", "type", plat.type());
@Override public void onOpen(ServerHandshake handshake) { platform.invokeLater(new Runnable() { public void run() { listener.onOpen(); } }); } };
public TripleDemo (Platform plat) { super(plat, 25); // update our "simulation" 40 times per second game = this; // jam ourselves into a global variable, woo! new Pointer(plat, rootLayer, true); // wire up event dispatch screens.push(new DemoMenuScreen(screens)); // start off with our menu screen // show debug rectangles when D key is pressed; dump scene graph on shift-D plat.input().keyboardEvents.collect(Keyboard.isKey(Key.D)).connect(event -> { Layer.DEBUG_RECTS = event.down; if (event.down && event.isShiftDown()) { rootLayer.debugPrint(plat.log()); } }); } }
/** * Returns the current time, as a double value in millis since January 1, 1970, 00:00:00 GMT. * * <p> This is equivalent to the standard JRE {@code new Date().getTime();}, but it slightly * terser, and avoids the use of {@code long} values, which are best avoided when translating to * JavaScript. </p> */ public static double currentTime() { return platform.time(); }
/** * Loads a JSON encoded library synchronously. * @param baseDir The base directory, containing library.json and texture atlases. */ public static Library loadLibrarySync (final Platform plat, String baseDir) throws Exception { final ImageLoader syncLoader = new ImageLoader() { @Override public Image load (String path) { return plat.assets().getImageSync(path); } }; String text = plat.assets().getTextSync(baseDir + "/library.json"); Try<Library> result = decodeLibrary(plat.json().parse(text), baseDir, syncLoader).result(); if (result.isSuccess()) return result.get(); Throwable error = result.getFailure(); if (error instanceof Exception) throw (Exception)error; else throw new RuntimeException(error); }
Exec exec () { return plat.exec(); }
/** * Returns the {@link Json} service. */ public static Json json() { return platform.json(); }
/** * Returns the {@link Storage} storage service. */ public static Storage storage() { return platform.storage(); }
/** * Returns the platform {@link Platform.Type}. */ public static Platform.Type platformType() { return platform.type(); }
if (plat.input().hasTouch()) { plat.input().touchEvents.connect(new Slot<Touch.Event[]>() { private int active = -1; @Override public void onEmit (Touch.Event[] events) { else if (plat.input().hasMouse()) { plat.input().mouseEvents.connect(new Slot<Mouse.Event>() { private boolean dragging; @Override public void onEmit (Mouse.Event event) { else plat.log().warn("Platform has neither mouse nor touch events?", "type", plat.type());
@Override public void onMessage(final String msg) { platform.invokeLater(new Runnable() { public void run() { listener.onTextMessage(msg); } }); }
private int elapsed(double start) { return (int)Math.round((game.plat.time() - start)/1000); }
Exec exec () { return plat.exec(); }