How to find the hitting(collision) of two Images

Anything libgdx related goes here!

How to find the hitting(collision) of two Images

Postby Subin » Fri Aug 16, 2019 2:42 pm

Hello everyone,,
I am new to libGDX framework, now i am developing one game. Here i am struggling on some areas which mentioned below,

I want to know that two images are collide or not, i am using below concept to check whether the two images are collide or not
openweb.onl/whatsapp-web/ modplus.pro/whatsapp-plus/
if(image1.getBoundingRectangle().overlaps(image2.getBoundingRectangle()))
{
//-----doing some logics----
}

In normal position(default angle) it's working fine but it's not working when image getting rotation.

example:

image1.setRotation(0f) - working
image1.setRotation(45f) - not working [working but its was not correct, when rotating its getBoundingRectangle() values height,width,x and y position all are changed]

Can any one please help me, its really appreciated

Thanks in Advance..
Last edited by Subin on Wed Aug 21, 2019 8:45 pm, edited 2 times in total.
Subin
 
Posts: 3
Joined: Fri Aug 16, 2019 2:27 pm

Re: How to find the hitting(collision) of two Images

Postby Zappp » Fri Aug 16, 2019 4:27 pm

Rotation won't work because you're getting a using a bounding rectangle of the image, that is the minimum rectangle that contains the whole image, I don't know if there is a direct way, but you can convert the bounds to a polygon and use Intersector
Zappp
 
Posts: 81
Joined: Sat Mar 29, 2014 3:34 am


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest