We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I am trying to make a window where it is possible to drag and drop different images and to make them overlap with a mouse click. Found a perfect example for it in openprocessing: https://www.openprocessing.org/sketch/540720 but I guess it would only work in p5.js
In processing library there are some examples of dragging the pictures, but they do so without mouse click and it is not possible to drop them. So I am wondering, is there any advanced example of drag & drop img that can run in Processing, or I better have to download this p5.js?
Cheers, tija
Answers
Also note that there is a new forum
https://discourse.processing.org/categories
Now I am trying to add more than one img to this code. Thanks for the fast reply and letting me know about the new forum.
Yeah just an array or ArrayList of Images
This is where I am now. Trying to stick more pictures by implementing some lines as I learn about arrays from tutorials. Yep, it doesn't work (shows that expecting {, found 'for'),but hope I am on the right path.
Definitely wrong. Very wrong.
Please do the tutorial on arrays and really run one of the examples from the tutorial!!!
The image is inside the class!!! So kill line 1 and 2!!!
What you want is
DraggingPic[] dragImages = new DraggingPic[4];
or so
Line 8 to 11
Later in the code use
for
loops: in draw, in mousePressed and mouseReleased —— but NOT inside the class obviouslyGood to now. Huge thanks. :)
;-)
Can you please post your new version as full code?
I tried to make it work, but because of lack of knowledge, I totally lost myself in code & gave up for this.
What?! It’s not so hard
here it is.
Please note that I didn't make any changes inside the class (almost no changes, but not related to our question of going from one image to multiple images).
Just outside of the class an array of class DraggingPic over which I for loop then in several places (for example in draw()) outside the class.
This
is just a for loop saying loop over all elements in dragImages and provide each element one after another as currentDraggingPic (which is of type DraggingPic) so I can use it inside the { } part of the for-loop.
The old fashioned way of saying the same is:
Chrisir ;-)