I am developing a game using libGDX. I am trying to detect the collision between bee and tube. I am using the following code to detect the collision.
if(player.getBounds().overlaps(boundsBot)){
}
player is a bee and boundsBot is Rectangle of tube. Since there is some transparency in bee image, this returns true even if it doesn't seem to collide. I understand the reason why this is returning true.
I read this solutions. I understood the theoretical concept to the solve the problem but I couldn't achieve it using libGDX.
Here is what I tried,
if(Intersector.intersectRectangles(player.getBounds(), boundsBot, rectangle)) {
//Gets the intersected rectangle
System.out.println("Rectangle Bottom: " + rectangle);
//Converting texture to pixmap
Texture texture = player.getTexture().getTexture();
if (!texture.getTextureData().isPrepared()) {
texture.getTextureData().prepare();
}
Pixmap pixmap = texture.getTextureData().consumePixmap();
//Trying to find transparency.....
System.out.println("Format: " + pixmap.getGLFormat());
}
How can I solve this issue?
Thank You!



