From bb5e2ff4012cc6427a52e745659cf4f205ad5de0 Mon Sep 17 00:00:00 2001 From: Eddy Date: Mon, 27 Mar 2023 01:19:34 +0200 Subject: [PATCH] new progress , succeded in moving the node with the mouse still not finished tho --- Piece/src/application/Piece.java | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/Piece/src/application/Piece.java b/Piece/src/application/Piece.java index acd3836..357320f 100644 --- a/Piece/src/application/Piece.java +++ b/Piece/src/application/Piece.java @@ -56,17 +56,16 @@ public class Piece extends Application{ //Instantiating RotateTransition class to create the animation (rotation to the left) RotateTransition rotatelft = new RotateTransition(); //setting attributes for the RotateTransition - rotatelft.setByAngle(-90); + rotatelft.setByAngle(-90);// minus to rotate to the left rotatelft.autoReverseProperty(); rotatelft.setDuration(Duration.millis(1000)); rotatelft.setNode(piece1); rotatelft.setAxis(Rotate.Z_AXIS); - /* */ - - piece1.setOnMousePressed(new EventHandler() { + //Mouse events handling + piece1.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent mouseEvent) { - // record a delta distance for the drag and drop operation. + // record a (x,y) distance for the drag and drop operation. x = piece1.getLayoutX() - mouseEvent.getSceneX(); y = piece1.getLayoutY() - mouseEvent.getSceneY(); piece1.setCursor(Cursor.CLOSED_HAND); @@ -96,9 +95,6 @@ public class Piece extends Application{ - - - scene.setOnKeyPressed(new EventHandler() { @@ -115,23 +111,6 @@ public class Piece extends Application{ } - /*public void pressed(MouseEvent event, Polygon piece1) { - piece1.setFill(Color.AZURE); - int x = piece1.getLayoutX() - MouseEvent.getSceneX(); - int y = piece1.getLayoutY() - MouseEvent.getSceneY(); - piece1.setCursor(Cursor.MOVE); - } - - public void dragged(MouseEvent event, Polygon piece1) { - piece1.setLayoutX(event.getSceneX()+ x); - piece1.setLayoutY(event.getSceneY()+ y); - piece1.draw(); - } - - public void released(MouseEvent event, Polygon piece1) { - piece1.setCursor(Cursor.HAND); - } - */ public static void main(String[] args) { launch(args);