We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am creating a dress up game. The setup is going to be base body on the left and organized clothes on the right. The user should click and drag the image to the body. There will be about 20-30 draggable items in total, so I want to make a function or class that can give all the images the same functionality rather than write the code 30 times.
I am not sure if my code is the most efficient way of doing that?
Also two problems currently:
When I click on an image, and that image makes contact with another, they both get stuck to the cursor.
The cursor feedback only works for the last image I draw, and is glitchy for the one before.
Here is my code so far (in the comments):
Answers
I think the problem is that more than one thing will match your mouse coords and the way the code is currently it'll move all the selected shapes.
Read the Common Question about arrays our classes. You'll need when you have 30 images.
It also has the benefit that when you're iterating over the array you can break when you get a match, meaning only the topmost item will move with the mouse.
continued here: https://forum.processing.org/two/discussion/24775/how-do-i-give-each-image-a-variable-value-through-a-loop