Advertisement
JackHoughton00

OldScene

Jun 12th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. Button btnStage2 = new Button("Start Game!");
  2. btnStage2.setOnAction(e -> {openMainWindow(stage);stage.hide();});
  3. Button btnClose = new Button("Close Game");
  4. btnClose.setOnAction(e -> stage.close());
  5.  
  6. HBox root = new HBox();
  7.  
  8.  
  9. //set height and width of buttons
  10. btnStage2.setPrefWidth(100);
  11. btnStage2.setPrefHeight(75);
  12. btnClose.setPrefWidth(100);
  13. btnClose.setPrefHeight(75);
  14.  
  15. // move the buttons to bottom of screen
  16. btnStage2.setTranslateX(50);
  17. btnStage2.setTranslateY(625);
  18. btnClose.setTranslateX(325);
  19. btnClose.setTranslateY(625);
  20.  
  21. root.getChildren().addAll(btnStage2,btnClose);
  22.  
  23. HBox root1 = new HBox();
  24. stage.setTitle("Block Dodger");
  25. Canvas canvas = new Canvas(550,350);
  26. canvas.setMouseTransparent(true);
  27. // combines the buttons and the text
  28. StackPane rootPane = new StackPane();
  29. Pane pane1 = new Pane();
  30. pane1 = root;
  31. Pane pane2 = new Pane();
  32. pane2 = root1;
  33. rootPane.getChildren().addAll(root,pane2);
  34. Scene scene = new Scene(rootPane,550,700);
  35. //Scene scene = new Scene(root,550,700);
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. GraphicsContext gc = canvas.getGraphicsContext2D();
  48.  
  49. gc.setFill( Color.AQUA);
  50.  
  51. gc.setStroke(Color.BLACK);
  52. gc.clearRect(0,0 ,550 , 700);
  53. gc.setLineWidth(2);
  54. Font theFont = Font.font("Arial", FontWeight.BOLD,28);
  55. gc.setFont( theFont);
  56. gc.fillText( "Welcome To The Block Dodger Game!",0,100);
  57. gc.strokeText("Welcome To The Block Dodger Game!", 0, 100);
  58. root1.getChildren().addAll(canvas);
  59. stage.setScene(scene);
  60. stage.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement