Drag and Drop for android

I’m new to processing but I have a good programming skills
I want to drag ie a square shape and drop it on another square , a kind of matching shapes games
could you help on that please.

more clarification : if I drag a square to another shape ie triangle , it will not accept.

thanks in advance.

That is possible. Can you show what you have so far? This can be done easily in processing java first and then run it in Android mode.


int x = 100;
int y = 100;
int sz = 100;

int x1 = 300;
int y1 = 100;

color bgcolor;
PShape rectangle;
PShape Ellipse;

void setup() {
  rectangle = createShape(RECT,x1-50,y1+80,sz,sz);
  Ellipse = createShape(ELLIPSE,x1,y1,sz,sz);
  size(400, 300);
  fill(random(255), 100, 200);

  background(color(255, 150, 255));
void draw() {
  background(color(255, 150, 255));
  if(dist(x,y, mouseX, mouseY) < sz / 2) {
    if(mousePressed) {
      x = mouseX;
      y = mouseY;
      if(x==x1&&y==y1){ stroke(0);strokeWeight(7);};//check if on the same coordinates
      if(x!=x1&&y!=y1){ noStroke();};
  ellipse(x, y, sz, sz);

what needs to be modified by the code is:
after moving the left circle to the right one I want to drop it there and forget about it.

is there is a way to find the match other than coordinates comparison.?

thanks in advance.