[LibGdx] Stuck with simple collision detection

Hi

I’m trying to do a simple collision detection with LibGDX’s intersector class. I draw the sprites so that it draws them from the center of the sprites and not from the bottom left corner of the sprite like it usually is. When I use sprite.getBoundingRectangle() method it doesn’t draw around the sprite but instead it draws it somewhere else because of the way I draw the sprites.

Enough talk, here is the code:

Drawing the sprite(class extends Sprite):

@Override
	public void draw(Batch batch) {
		batch.draw(this.getTexture(), this.getX() - this.getOriginX(), this.getY() - this.getOriginY(),
				this.getOriginX(), this.getOriginY(), this.getWidth(), this.getHeight(), 1.0f, 1.0f,
			    0, this.getRegionX(), this.getRegionY(),
			    this.getRegionWidth(), this.getRegionHeight(), false, false
			);
	}

Checking collision:

public void checkCollisions(Object obj){
		if(obj instanceof Enemy && Intersector.overlaps(this.getBoundingRectangle(), ((Paddle) obj).getBoundingRectangle())){
			this.speed.y = -this.speed.y;
		}
	}

What should I do to fix this?

Things to check first:

  • Do a simple sysout do check the co-ords of the boundary box.
  • Try a point intersection using the mouse co ords
  • Check when this is getting called if at all