title: Bitmap Bounding RectF Collision
body: <p>I have been trying to create a simple breakout type game. I have a ball and a bat and want to invert the ball's direction when it collides with the bat. The bat is controlled by the user's touch and can freely move around the screen.</p>
  
  <pre><code>@Override
  public boolean onTouch(View v, MotionEvent event) {
      x = (int) event.getX();
      y = (int) event.getY();
      return true;
  }
  </code></pre>
  
  <hr>
  
  <p>In my game loop:</p>
  
  <pre><code>    int cx = -1;
      int cy = -1;
  
      private int xVelocity = -11;
      private int yVelocity = -14;
  
      Bitmap player, ball;
      RectF boundsPlayer, boundsBall;
  
      float boundCX, boundCY;
  </code></pre>
  
  <hr>
  
  <pre><code>    boundCX = (float) cx;
      boundCY = (float) cy;
      player = BitmapFactory.decodeResource(getResources(), R.drawable.nightplayer);
      canvas.drawBitmap(player, x - (player.getWidth() / 2), y - (player.getHeight() + 100), null);
  
      ball = BitmapFactory.decodeResource(getResources(), R.drawable.ball);
  
      boundsPlayer = new RectF((x - (player.getWidth()/2)), (y - (player.getHeight() + 150)), ((x - (player.getWidth()/2)) + player.getWidth()), ((y - (player.getHeight() + 150)) + player.getHeight()));
      boundsBall = new RectF(boundCX, boundCY, boundCX + ball.getWidth(), boundCY + ball.getHeight());
  
      if (RectF.intersects(boundsBall, boundsPlayer)) {
                         collision();
      }
  
  private void collision() {
          yVelocity = yVelocity * -1;
          score = score + 1;
          //Log.d(TAG, String.valueOf(score));
          yVelocity = yVelocity - 2;
          if(xVelocity &lt; 0) {
              xVelocity = xVelocity - 2;
          } else if (xVelocity &gt; 0) {
              xVelocity = xVelocity + 2;
          }
          collision = false;
      }
  </code></pre>
  
  <p>The issue I am having is that when the ball collides with the bat it seems to collide multiple times and repeatedly inverts the direction instead of "bouncing off" of the bat.</p>