你好我想在我的java游戏中删除一个名为treeicon的imageicon,我发现我的if语句有问题。如果布尔drawimage等于false,我将如何删除图像树?
if(r1.intersects(rectX, rectY, 25, 25)){
g.drawString("Cut Down Some Tree's To Get Some Wood To build Your Base", rectX, rectX);
drawimage = true;
}
if(drawimage){
g.drawImage(tree,175, 75, 50, 50,null);
//Check if the image has cloision
if(r1.intersects(175, 75, 50, 50)){
drawimage = false;
}
if(!drawimage){
}
}
repaint();
}
答案 0 :(得分:0)
更正您的代码
if(drawimage = false){ }
到if(drawimage == false){ }
或
if(!drawimage){ }