【发布时间】:2020-11-09 02:34:26
【问题描述】:
我正在努力做到这一点,以便当用户单击程序中的铅笔图标时,他们被允许绘制,直到再次单击铅笔。我还没有在切换中添加,但我目前的问题是我在我指定的鼠标区域中获得了所需的行为,但在屏幕上没有其他地方,还请原谅我的代码在玩它时会发生很多变化,但是通过运行它在当前状态下,您应该会看到我在说什么错误。
谢谢
PImage[] img = new PImage[3];
boolean drawPencil = false;
boolean draw = false;
void setup() {
size(960, 720);
for (int i = 0; i < img.length; i++)
img[i] = loadImage("image"+i+".png");
//an array of images that sorts and load them into our program
image(img[0],0,0);
img[0].resize(width, height);
// set the desired image to screen size
}
void mousePressed() {
if (mouseX > 772 && mouseX < 864 && mouseY > 1 && mouseY < 74) {
drawPencil = true;
draw = true;
// if the user clicks the pencil icon they will begin to draw
}
}
void mouseReleased()
{
draw = false;
}
void draw() {
if (draw) {
stroke(255);
line(mouseX, mouseY, pmouseX, pmouseY);
}
if (key == 'w'||key == 'W') {
image(img[0],0,0);
img[0].resize(width, height);
println(drawPencil);
}
}
【问题讨论】:
标签: processing