reda
July 23, 2018, 5:50pm
1
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.
Kf
reda
July 24, 2018, 5:10pm
3
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.