Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.98 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How use wait for batch in Libgdx
  2. public void render() {
  3.     x = rand.nextFloat() * 1024;
  4.     y = rand.nextFloat() * 700;
  5.     Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  6.     batch.begin();
  7.     batch.draw(texture, x, y);
  8.     if (Gdx.input.justTouched()) {
  9.         if (Gdx.input.getX() > x && Gdx.input.getX() < texture.getWidth() + x) {
  10.             if (Gdx.input.getY() > y && Gdx.input.getY() < texture.getHeight() + y) {
  11.                 batch.end();
  12.             }
  13.         }
  14.     }
  15. }
  16.        
  17. public void render() {
  18.     x = rand.nextFloat() * 1024;
  19.     y = rand.nextFloat() * 700;
  20.     Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  21.     batch.begin();
  22.     batch.draw(texture, x, y);
  23.     try {
  24.         batch.wait();
  25.     } catch (InterruptedException e) {
  26.         // TODO Auto-generated catch block
  27.         e.printStackTrace();
  28.     }
  29.     batch.end();
  30. }
  31.        
  32. public void render() {
  33.   ...
  34.   if(Gdx.input.isButtonPressed(Buttons.LEFT)) {
  35.       //move sprite left
  36.   }
  37. }
  38.        
  39. Gdx.input.setInputProcessor(yourInputProcessor);