Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p.getPiece().setOnMouseDragged(event -> {
- for(int i = 0;i<p.getFaces().length;i++) {
- if (event.isPrimaryButtonDown()) {
- double dx = mousePosX - event.getSceneX();
- double dy = mousePosY - event.getSceneY();
- if (Math.abs(dy) > Math.abs(dx) && !up ) {
- if (dy >= 0) {
- up = true;
- // System.out.println(ro);
- Timeline tl = new Timeline(
- new KeyFrame(Duration.ZERO, new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle())),
- new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle() - 90d))
- );
- tl.setCycleCount(1);
- tl.play();
- tl.setOnFinished(event1 -> up = false);
- System.out.println("up");
- } else {
- up = true;
- Timeline tl = new Timeline(
- new KeyFrame(Duration.ZERO, new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle())),
- new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle() + 90d))
- );
- tl.setCycleCount(1);
- tl.play();
- tl.setOnFinished(event1 -> up = false);
- System.out.println("down");
- }
- }else if(Math.abs(dx) > Math.abs(dy) && !up)
- {
- if (dx >= 0) {
- up = true;
- Timeline tl = new Timeline(
- new KeyFrame(Duration.ZERO, new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle())),
- new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle() + 90d))
- );
- tl.setCycleCount(1);
- tl.play();
- tl.setOnFinished(event1 -> up = false);
- System.out.println("right");
- } else {
- up = true;
- Timeline tl = new Timeline(
- new KeyFrame(Duration.ZERO, new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle())),
- new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle() - 90d))
- );
- tl.setCycleCount(1);
- tl.play();
- tl.setOnFinished(event1 -> up = false);
- System.out.println("left");
- }
- }
- moving = true;
- }
- }
- });
Add Comment
Please, Sign In to add comment