0
我是新來的處理,並試圖找出爲什麼這是發生在draw()下。 根據我放置矩形的位置,該圓形確實或不出現。我的目標是在矩形前獲得可拖動的圓。Processing Shape Placement
int x;
int y;
public void setup()
{
size(600, 600);
}
public void draw()
{
background(255);
// if timeLine() placed here, circle doesn't appear
circle();
timeLine(); // if timeline placed here, circle appears behind rectangle
}
public void circle()
{
ellipse(this.x, height/2, 10, 10);
}
public void mouseDragged()
{
translate(width/2, height/2);
this.x = mouseX;
this.y = mouseY;
}
public void mousePressed()
{
translate(width/2, height/2);
if (mouseY < height/2 + 10 && mouseY > height/2 - 10) {
this.x = mouseX;
}
}
public void timeLine()
{
translate(width/2, height/2);
rectMode(CENTER);
rect(0, 0, 2, 20);
}