【发布时间】:2014-10-28 20:09:07
【问题描述】:
我是 Processing 的新手,并试图弄清楚为什么会在 draw() 下发生这种情况。 根据我放置矩形创建的位置,圆圈出现或不出现。我的目标是在矩形前面获得可拖动的圆圈。
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);
}
【问题讨论】:
标签: processing