从画布中删除 GraphicsContext 形状

问题描述

我运行了一个小游戏,我想知道如何删除/删除 GraphicsContext 中的形状。 当其中一个 if 语句适合时,我想删除一个 Rectangle 。可悲的是,我不知道是否有删除它的方法

希望你能帮帮我

targets.setFill(Color.RED);
            //Problem area
            for (countCol = 1; countCol <= 10; countCoL++) {
                for (countRow = 1; countRow <= 3; countRow++) {
                    targets.fillRect(countRow * gapX + startX,countCol * gapY + startY,brickW,brickH);
                    if (ballXPos + rad >= (countRow * gapX + startX) && ballXPos + rad <= (countRow * gapX + startX) + brickW && ballYPos + rad == (countCol * gapY + startY)) {
                        ballYSpeed *= -1;
                    }
                    if (ballXPos + rad >= (countRow * gapX + startX) && ballXPos + rad <= (countRow * gapX + startX) + brickW && ballYPos + rad == (countCol * gapY + startY) + brickH) {
                        ballYSpeed *= -1;
                    }
                    if (ballXPos + rad == (countRow * gapX + startX) && ballYPos + rad >= (countCol * gapY + startY) && ballYPos + rad <= (countCol * gapY + startY) + brickH) {
                        ballXSpeed *= -1;
                    }
                    if (ballXPos + rad == (countRow * gapX + startX) + brickW && ballYPos + rad >= (countCol * gapY + startY) && ballYPos + rad <= (countCol * gapY + startY) + brickH) {
                        ballXSpeed *= -1;
                    }
                }
            }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)