diff --git a/Example4M.java b/Example4M.java index 9fe4017..8280c90 100644 --- a/Example4M.java +++ b/Example4M.java @@ -1,5 +1,6 @@ import javafx.application.Application; import javafx.stage.Stage; +import javafx.scene.shape.Circle; import javafx.scene.Scene; import javafx.scene.Group; import javafx.scene.canvas.Canvas; @@ -11,7 +12,6 @@ import javafx.animation.AnimationTimer; import javafx.event.EventHandler; import javafx.scene.input.MouseEvent; -import java.util.ArrayList; // Keyboard events public class Example4M extends Application @@ -43,11 +43,12 @@ public void start(Stage theStage) { public void handle(MouseEvent e) { - if ( targetData.containsPoint( e.getX(), e.getY() ) ) + if ( targetData.contains( e.getX(), e.getY() ) ) { double x = 50 + 400 * Math.random(); double y = 50 + 400 * Math.random(); - targetData.setCenter(x,y); + targetData.setCenterX(x); + targetData.setCenterY(y); points.value++; } else @@ -73,8 +74,8 @@ public void handle(long currentNanoTime) gc.fillRect(0,0, 512,512); gc.drawImage( bullseye, - targetData.getX() - targetData.getRadius(), - targetData.getY() - targetData.getRadius() ); + targetData.getCenterX() - targetData.getRadius(), + targetData.getCenterY() - targetData.getRadius() ); gc.setFill( Color.BLUE ); @@ -87,4 +88,4 @@ public void handle(long currentNanoTime) theStage.show(); } -} \ No newline at end of file +}