title: Is this the right way to detect a touch on a rectangle in LibGdx ? Does not seem to be working for me
body: <p>This is the code for my gamescreen where i want burst my ballon when its touched .
  orientation is portrait.
  but it does not seem to work for me.</p>
  
  <pre><code> public class GameScreen implements Screen {
      final BB game;
      private BitmapFont font;
      private static final int no_of_frames = 2;
      Texture ballonFrames;
      TextureRegion[] burstFrames = new TextureRegion[no_of_frames];
      Animation burstAnimation;
      Array&lt;Rectangle&gt; ballons;
      TextureRegion currentFrame;
      long lastBallonTime;
      int ballonBursted;
      OrthographicCamera camera;
      int ballonMissed;
  
      Sound ballonBursting;
  
      public GameScreen(final BB gam) {
          this.game = gam;
  
          ballonFrames = new Texture(Gdx.files.internal("ballon_burst.png"));
          font = new BitmapFont(Gdx.files.internal("font.fnt"), false);
          ballonBursting = Gdx.audio.newSound(Gdx.files
                  .internal("BallonBursting.wav"));
          TextureRegion[][] tmp = TextureRegion.split(ballonFrames,
                  ballonFrames.getWidth() / 2, ballonFrames.getHeight());
          burstFrames[0] = tmp[0][0];
          burstFrames[1] = tmp[0][1];
  
          burstAnimation = new Animation(3.0f, burstFrames);
          camera = new OrthographicCamera();
          camera.setToOrtho(false, 800, 480);
  
          ballons = new Array&lt;Rectangle&gt;();
  
          spawnBallon();
  
      }
  
      private void spawnBallon() {
          Rectangle ballon = new Rectangle();
          ballon.x = MathUtils.random(0, 800 - 64); //
          ballon.y = 0;
          ballon.width = 40;
          ballon.height = 80;
          ballons.add(ballon);
          lastBallonTime = TimeUtils.nanoTime();
      }
  
      private boolean ballonBursted(Rectangle ballon) {
          Vector2 touch = new Vector2(Gdx.input.getX(), Gdx.input.getY());
          if (ballon.contains(touch))
              return true;
          else
              return false;
      }
  
      @Override
      public void render(float delta) {
          // TODO Auto-generated method stub
          Gdx.gl.glClearColor(0, 0, 0.3f, 1);
          Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
          InputProcessor processor;
  
          camera.update();
          game.batch.setProjectionMatrix(camera.combined);
          game.batch.begin();
          font.draw(game.batch, "Ballon Bursted :" + ballonBursted, 0, 700);
          font.draw(game.batch, "Ballon Missed:" + ballonMissed, 275, 700);
          for (Rectangle ballon : ballons) {
              game.batch.draw(burstFrames[0], ballon.x, ballon.y);
          }
  
          if (TimeUtils.nanoTime() - lastBallonTime &gt; 1000000000) {
              spawnBallon(); // a ballon every second
          }
  
          Iterator&lt;Rectangle&gt; iter = ballons.iterator();
          while (iter.hasNext()) {
              Rectangle ballon = iter.next();
              ballon.y = ballon.y + 100 * Gdx.graphics.getDeltaTime();
  
              if (ballonBursted(ballon) == true) {
                  ballonBursted++;
                  game.batch.draw(burstFrames[1], ballon.x, ballon.y);
                  ballonBursting.play();
                  iter.remove();
              }
              else if (ballon.y + 64 &gt; 800) {
                  iter.remove();
                  ballonMissed++;
              }
          }
  
          if (ballonMissed &gt; 5) {
              game.setScreen(new ScoreScreen(game, ballonBursted));
          }
          game.batch.end();
      }
  
      @Override
      public void resize(int width, int height) {
  
      }
  
      @Override
      public void show() {
  
      }
  
      @Override
      public void hide() {
  
      }
  
      @Override
      public void pause() {
  
      }
  
      @Override
      public void resume() {
  
      }
  
      @Override
      public void dispose() {
          ballonFrames.dispose();
          ballonBursting.dispose();
          game.batch.dispose();
  
      }
  </code></pre>
  
  <p>I am using animation class of libgdx to change my image of ballon to the one where its bursted .
  I am fairly new to libgdx and unable to figure out what wrong am i doing here .
  Should i create a table and layout my ballon elements as actor?</p>