0
我已经创建了一个大拇指网格。当按下特定的拇指时,我想要在屏幕上添加与拇指链接的图像。我知道我应该在setup()中写入loadImages,但是我对如何做到这一点感到困惑。在屏幕上获取形状
PShape[] Quotes = new PShape[6];
int qLength = Quotes.length;
setup() {
size(1024, 768);
}
draw() {
stroke(bruin);
strokeWeight(5);
fill(wit);
rectMode(CORNER);
rect(guide, 280, bBorder, 145);
noStroke();
fill(bruin);
rect(guide, 280, bBorder, 40);
textFont(kaffeesatzFont);
textSize(30);
fill(wit);
text("Quotes", 80, 308);
createGridQ();
}
void createGridQ(){
xOffset = 30;
yOffset = 325;
xSize = 50;
ySize = 38;
padding = 10;
xPos = padding + xOffset;
yPos = yOffset;
cols = 3;
for(int j = 0; j < qLength; j++){
// Grid
xPos = xOffset + ((j % cols) * (xSize+padding));
yPos = yOffset + ((j/cols) * (ySize+padding));
Quotes[j] = loadShape("Q" + j + ".svg");
shape(Quotes[j], xPos, yPos);
if((mouseX >= xPos) && (mouseX <= xPos+xSize) &&
(mouseY >= yPos) && (mouseY <= yPos+ySize)){
cursor(HAND);
if (mousePressed){
cursor(HAND);
Quotes[j] = loadShape("Q" + j + "groot" + ".svg");
shape(Quotes[j], width/5, height/2-200);
}
}
}
}
我知道这一点。问题是当我点击连接到形状的拇指时,它只在单击鼠标时出现(mousePressed),显然,我希望它在点击时添加在屏幕上。 – user3221136
如果您知道所有将事先使用的图像,请将它们安装到您选择的数据结构中。存储具有图像索引和位置的对象的另一个数据结构。当单击一个拇指时,将点击位置和图像的索引存储到书写和每个绘制循环中,迭代绘制所有对象的列表。 – aclegg3