# Drag and Drop for android

**URL:** <https://discourse.processing.org/t/drag-and-drop-for-android/2019>\
**Category:** Coding Questions\
**Created:** [July 23, 2018, 5:50pm UTC](https://discourse.processing.org/t/drag-and-drop-for-android/2019 "2018-07-23T17:50:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reda](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@reda](https://discourse.processing.org/u/reda)\
**Post date:** [July 23, 2018, 5:50pm UTC](https://discourse.processing.org/t/drag-and-drop-for-android/2019/1 "2018-07-23T17:50:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 24, 2018, 3:26am UTC](https://discourse.processing.org/t/drag-and-drop-for-android/2019/2 "2018-07-24T03:26:37Z")

</div>

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.

Kf

---

<div class="post-metadata">

**Author:** ![reda](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@reda](https://discourse.processing.org/u/reda)\
**Post date:** [July 24, 2018, 5:10pm UTC](https://discourse.processing.org/t/drag-and-drop-for-android/2019/3 "2018-07-24T17:10:19Z")

</div>

```auto
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);
  colorMode(HSB);
  noStroke();
  smooth();
  
  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();};
    }
    
  } 
  shape(Ellipse);
  shape(rectangle);
  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.  
secondly

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

thanks in advance.
