Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scene theScene = new Scene ( root );
- stage.setScene ( theScene );
- Canvas canvas = new Canvas( 550,700);
- root.getChildren().add(canvas);
- GraphicsContext gc = canvas.getGraphicsContext2D();
- gc.setFill( Color.AQUA);
- gc.setStroke(Color.BLACK);
- gc.setLineWidth(2);
- Font theFont = Font.font("Arial", FontWeight.BOLD,48);
- gc.setFont( theFont);
- gc.fillText( "Welcome to the game!", 60,50);
- gc.strokeText("Welcome to the game!", 60, 50);
- Image triangle1 = new Image("triangle1.png");
- gc.drawImage(triangle1, 250, 250);
- Image triangle2 = new Image("triangle2.png");
- gc.drawImage(triangle2, 290, 250);
- Image triangle3 = new Image("triangle3.png");
- gc.drawImage(triangle3, 215, 250);
- Image cursor1 = new Image("cursor1.png");
- gc.drawImage(cursor1, 400, 250);
- final long startNanoTime = System.nanoTime();
- new AnimationTimer() {
- public void handle(long currentNanoTime) {
- double t = (currentNanoTime - startNanoTime) / 1000000000.0;
- double x = 232 + 128 * Math.cos(t);
- double y = 232 + 128 * Math.sin(t);
- Image cursor2 = new Image("cursor2.png");
- gc.drawImage(cursor2, 150, 250);
- }
- }.start();
- stage.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement