微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从画布中删除 GraphicsContext 形状

如何解决从画布中删除 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 举报,一经查实,本站将立刻删除。