-3

I was coding a simple shape-collision-detector, but I noticed the rectangle which I move using the mouse vanishes in some window's areas. I can't figure out why.

Here you can see the video and below the code I used. Any advice?

Rectangle r = new Rectangle();
r.setWidth(150);
r.setHeight(150);

Group root = new Group(r, e, boh);

Scene scene = new Scene(root, 1000, 1000);

scene.setOnMouseDragged(ev -> {
    r.setX(ev.getX() - r.getWidth() / 2);
    r.setY(ev.getY() - r.getHeight() / 2);
});
Barett
  • 5,826
  • 6
  • 51
  • 55
  • 1
    SO is a terrible debugger. Advice here: https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ –  Apr 02 '18 at 21:06
  • https://github.com/sedj601/CollisionDectionFx/blob/master/src/collisiondection/FXMLDocumentController.java – SedJ601 Apr 04 '18 at 14:07

1 Answers1

-2

I solved by placing another Rectangle as background.