public Lwjgl3ControllerManager() { Gdx.app.postRunnable(new Runnable() { @Override public void run () { pollState(); Gdx.app.postRunnable(this); } }); }
@Override public void cancelled () { Gdx.app.postRunnable(new Runnable() { public void run () { setButtonDisabled(false); Gdx.app.log("NetAPITest", "HTTP request cancelled"); statusLabel.setText("HTTP request cancelled"); } }); }
@Override public void onCompletion (MediaPlayer mp) { if (onCompletionListener != null) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { onCompletionListener.onCompletion(AndroidMusic.this); } }); } }; }
@Override public void onCompletion (MediaPlayer mp) { if (onCompletionListener != null) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { onCompletionListener.onCompletion(AndroidMusic.this); } }); } }; }
@Override public void audioPlayerDidFinishPlayingSuccessfully (AVAudioPlayer player, boolean flag) { final OnCompletionListener listener = onCompletionListener; if (onCompletionListener != null) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.onCompletion(IOSMusic.this); } }); } } };
@Override public void didFinishPlaying (NSObject player, boolean success) { final OnCompletionListener listener = onCompletionListener; if (listener != null) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.onCompletion(IOSMusic.this); } }); } } });
@Override public void audioPlayerDidFinishPlayingSuccessfully (AVAudioPlayer player, boolean flag) { final OnCompletionListener listener = onCompletionListener; if (onCompletionListener != null) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.onCompletion(IOSMusic.this); } }); } } };
@Override public void didFinishPlaying (NSObject player, boolean success) { final OnCompletionListener listener = onCompletionListener; if (listener != null) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.onCompletion(IOSMusic.this); } }); } } });
public boolean keyDown (InputEvent event, int keycode2) { if (keycode == keycode2) { // Delay a frame to eat the keyTyped event. Gdx.app.postRunnable(new Runnable() { public void run () { result(object); if (!cancelHide) hide(); cancelHide = false; } }); } return false; } });
public boolean keyDown (InputEvent event, int keycode2) { if (keycode == keycode2) { // Delay a frame to eat the keyTyped event. Gdx.app.postRunnable(new Runnable() { public void run () { result(object); if (!cancelHide) hide(); cancelHide = false; } }); } return false; } });
@Override public void run () { pollState(); Gdx.app.postRunnable(this); } });
void setText (HttpResponse httpResponse) { final String newText = httpResponse.getResultAsString(); Gdx.app.postRunnable(new Runnable() { public void run () { text = newText; } }); }
@Override public void handleHttpResponse (HttpResponse httpResponse) { final byte[] bytes = httpResponse.getResult(); Gdx.app.postRunnable(new Runnable() { @Override public void run () { Pixmap pixmap = new Pixmap(bytes, 0, bytes.length); texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), false, false, true)); } }); }
@Override public void render () { if (Gdx.input.justTouched()) { expectIt = true; Gdx.app.postRunnable(new Runnable() { @Override public void run () { throw new RuntimeException("This is a test of the uncaught exception handler."); } }); } } }
@Signature public PGdxGame later(Invoker invoker) { Gdx.app.postRunnable(new Runnable() { @Override public void run() { invoker.callAny(); } }); return this; }
synchronized long update (long timeMillis, long waitMillis) { for (int i = 0, n = tasks.size; i < n; i++) { Task task = tasks.get(i); synchronized (task) { if (task.executeTimeMillis > timeMillis) { waitMillis = Math.min(waitMillis, task.executeTimeMillis - timeMillis); continue; } if (task.repeatCount == 0) { task.timer = null; tasks.removeIndex(i); i--; n--; } else { task.executeTimeMillis = timeMillis + task.intervalMillis; waitMillis = Math.min(waitMillis, task.intervalMillis); if (task.repeatCount > 0) task.repeatCount--; } task.app.postRunnable(task); } } return waitMillis; }
synchronized long update (long timeMillis, long waitMillis) { for (int i = 0, n = tasks.size; i < n; i++) { Task task = tasks.get(i); synchronized (task) { if (task.executeTimeMillis > timeMillis) { waitMillis = Math.min(waitMillis, task.executeTimeMillis - timeMillis); continue; } if (task.repeatCount == 0) { task.timer = null; tasks.removeIndex(i); i--; n--; } else { task.executeTimeMillis = timeMillis + task.intervalMillis; waitMillis = Math.min(waitMillis, task.intervalMillis); if (task.repeatCount > 0) task.repeatCount--; } task.app.postRunnable(task); } } return waitMillis; }
@Override public void beginContact (Contact contact) { System.out.println(String.format("beginContact() addr=%d", getContactAddr(contact))); System.out.println(String.format("beginContact() addrA=%d, addrB=%d", getFixtureAddrA(contact), getFixtureAddrB(contact))); System.out.println(String.format("beginContact() fixA=%s, fixB=%s", contact.getFixtureA(), contact.getFixtureB())); final Body toRemove = contact.getFixtureA().getBody().getType() == BodyType.DynamicBody ? contact.getFixtureA().getBody() : contact.getFixtureB().getBody(); Gdx.app.postRunnable(new Runnable() { @Override public void run () { world.destroyBody(toRemove); } }); }
Gdx.app.postRunnable(this);
@Override public void run () { byte[] bytes = new byte[200 * 1024]; // assuming the content is not bigger than 200kb. int numBytes = download(bytes, "http://www.badlogicgames.com/wordpress/wp-content/uploads/2012/01/badlogic-new.png"); if (numBytes != 0) { // load the pixmap, make it a power of two if necessary (not needed for GL ES 2.0!) Pixmap pixmap = new Pixmap(bytes, 0, numBytes); final int originalWidth = pixmap.getWidth(); final int originalHeight = pixmap.getHeight(); int width = MathUtils.nextPowerOfTwo(pixmap.getWidth()); int height = MathUtils.nextPowerOfTwo(pixmap.getHeight()); final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat()); potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); pixmap.dispose(); Gdx.app.postRunnable(new Runnable() { @Override public void run () { image = new TextureRegion(new Texture(potPixmap), 0, 0, originalWidth, originalHeight); } }); } } }).start();