Guest User

Untitled

a guest
Nov 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. p.getPiece().setOnMouseDragged(event -> {
  2.  
  3. for(int i = 0;i<p.getFaces().length;i++) {
  4. if (event.isPrimaryButtonDown()) {
  5.  
  6. double dx = mousePosX - event.getSceneX();
  7. double dy = mousePosY - event.getSceneY();
  8.  
  9. if (Math.abs(dy) > Math.abs(dx) && !up ) {
  10.  
  11. if (dy >= 0) {
  12. up = true;
  13. // System.out.println(ro);
  14.  
  15. Timeline tl = new Timeline(
  16. new KeyFrame(Duration.ZERO, new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle())),
  17. new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle() - 90d))
  18. );
  19. tl.setCycleCount(1);
  20. tl.play();
  21. tl.setOnFinished(event1 -> up = false);
  22. System.out.println("up");
  23. } else {
  24. up = true;
  25.  
  26. Timeline tl = new Timeline(
  27. new KeyFrame(Duration.ZERO, new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle())),
  28. new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateX.angleProperty(), p.rotateX.getAngle() + 90d))
  29. );
  30. tl.setCycleCount(1);
  31. tl.play();
  32. tl.setOnFinished(event1 -> up = false);
  33.  
  34. System.out.println("down");
  35. }
  36.  
  37. }else if(Math.abs(dx) > Math.abs(dy) && !up)
  38. {
  39. if (dx >= 0) {
  40. up = true;
  41. Timeline tl = new Timeline(
  42. new KeyFrame(Duration.ZERO, new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle())),
  43. new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle() + 90d))
  44. );
  45. tl.setCycleCount(1);
  46. tl.play();
  47. tl.setOnFinished(event1 -> up = false);
  48. System.out.println("right");
  49. } else {
  50. up = true;
  51.  
  52. Timeline tl = new Timeline(
  53. new KeyFrame(Duration.ZERO, new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle())),
  54. new KeyFrame(Duration.seconds(1), new KeyValue(p.rotateY.angleProperty(), p.rotateY.getAngle() - 90d))
  55. );
  56. tl.setCycleCount(1);
  57. tl.play();
  58. tl.setOnFinished(event1 -> up = false);
  59. System.out.println("left");
  60. }
  61.  
  62.  
  63.  
  64.  
  65. }
  66. moving = true;
  67. }
  68. }
  69. });
Add Comment
Please, Sign In to add comment