Jump to content

Image collision


Karoffe

Recommended Posts

Posted

Hello. i will make a bunch of images move, I want to know whenever an images touches an other, the image gets destroyed, I know almost everything, just how to know if the image touched an other one ?

Posted

Check the position and size of each image, if they are 1 pixel offset from eachother, it's touching.

"The humble beet is the answer to all riddles." - Rolf

Posted

You know the size and position of the image since you made it. Image 1 is at 100x100 and is 250x250 so its coordinates are 100x100, 100x350, 350x350, 350x100. Image 2 is at 351x100 and is 100x100 wide, so its coordinates are 351x100, 451x100, 451x200, 351x200. They are 1 pixel apart, therefor touching. Or if some of the coordinates are between two others, they could be considered overlapped.

"The humble beet is the answer to all riddles." - Rolf

Posted

Problem is these would work if the images are not in rotation, so that way will work when the bounding boxes touches eachother, I want it to be with the image itself, Anyways i personally thought of doing your way easier by getDistanceBetweenPoints2D.. but still won't work with rotated images

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...