How to use intersect() method of Node Class in JavaFX?


Question

JavaFX Node class provides two intersect methods:

 intersects(Bounds localBounds);

and

 intersects(double localX, double localY, double localWidth, double localHeight);

When and how can I use these methods?

1
1
12/30/2013 1:31:43 PM

Accepted Answer

as it name tells it is used to determine if a node is intersected with other node or not..

Example : If you're going to develop Zen pong game in javafx ,if ball hits the wall behind paddle then game over.

Code :

   private  Circle ball;
   private  Rectangle wall;
   if(ball.intersects(wall.getBoundsInLocal()) {
        //game over
    }
2
1/1/2014 1:35:35 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon