Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button btnStage2 = new Button("Start Game!");
- btnStage2.setOnAction(e -> {openMainWindow(stage);stage.hide();});
- Button btnClose = new Button("Close Game");
- btnClose.setOnAction(e -> stage.close());
- HBox root = new HBox();
- //set height and width of buttons
- btnStage2.setPrefWidth(100);
- btnStage2.setPrefHeight(75);
- btnClose.setPrefWidth(100);
- btnClose.setPrefHeight(75);
- // move the buttons to bottom of screen
- btnStage2.setTranslateX(50);
- btnStage2.setTranslateY(625);
- btnClose.setTranslateX(325);
- btnClose.setTranslateY(625);
- root.getChildren().addAll(btnStage2,btnClose);
- HBox root1 = new HBox();
- stage.setTitle("Block Dodger");
- Canvas canvas = new Canvas(550,350);
- canvas.setMouseTransparent(true);
- // combines the buttons and the text
- StackPane rootPane = new StackPane();
- Pane pane1 = new Pane();
- pane1 = root;
- Pane pane2 = new Pane();
- pane2 = root1;
- rootPane.getChildren().addAll(root,pane2);
- Scene scene = new Scene(rootPane,550,700);
- //Scene scene = new Scene(root,550,700);
- GraphicsContext gc = canvas.getGraphicsContext2D();
- gc.setFill( Color.AQUA);
- gc.setStroke(Color.BLACK);
- gc.clearRect(0,0 ,550 , 700);
- gc.setLineWidth(2);
- Font theFont = Font.font("Arial", FontWeight.BOLD,28);
- gc.setFont( theFont);
- gc.fillText( "Welcome To The Block Dodger Game!",0,100);
- gc.strokeText("Welcome To The Block Dodger Game!", 0, 100);
- root1.getChildren().addAll(canvas);
- stage.setScene(scene);
- stage.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement