Karoffe Posted October 31, 2014 Posted October 31, 2014 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 ?
Woovie Posted October 31, 2014 Posted October 31, 2014 Check the position and size of each image, if they are 1 pixel offset from eachother, it's touching.
Woovie Posted October 31, 2014 Posted October 31, 2014 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.
Karoffe Posted November 1, 2014 Author Posted November 1, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now