windows端打字遊戲——功能選擇

來源:互聯網
上載者:User

標籤:show   run   art   icons   getc   list   login   tar   ane   

MainFace類主要實現登入遊戲後功能選擇介面。

import javafx.application.Application;

import javafx.event.EventHandler;

import javafx.scene.Cursor;

import javafx.scene.Scene;

import javafx.scene.image.Image;

import javafx.scene.image.ImageView;

import javafx.scene.input.MouseEvent;

import javafx.scene.layout.Pane;

import javafx.stage.Stage;

import javafx.stage.WindowEvent;

 

public class MainFace extends Application{

   private Image background=new Image("background.jpg");

  private Image bong2=new Image("bong2.png");

  private Image bong3=new Image("bong3.png");

  private Image char_bg=new Image("char_bg.png");

  private Image head=new Image("head.png");

  private Image s_head=new Image("smallhead.png");

  private Image choice1=new Image("choice1.png");

  private Image choice2=new Image("choice2.png");

  private Image choice3=new Image("choice3.png");

  public void start(Stage primaryStage){

    ImageView img_bg=new ImageView(background);

    ImageView img_ch1_bg=new ImageView(bong2);

    ImageView img_ch2_bg=new ImageView(bong2);

    ImageView img_ch3_bg=new ImageView(bong2);

    ImageView img_head1=new ImageView(bong3);

    ImageView img_head2=new ImageView(bong3);

    ImageView img_head3=new ImageView(bong3);

    ImageView img_head4=new ImageView(bong3);

    ImageView img_head=new ImageView(head);

    ImageView img_s_head=new ImageView(s_head);

    ImageView img_choice1=new ImageView(choice1);

    ImageView img_choice2=new ImageView(choice2);

    ImageView img_choice3=new ImageView(choice3);

    img_bg.setFitWidth(600);

    img_bg.setFitHeight(400);

    img_choice1.setX(270);

    img_choice1.setY(205);

    img_choice2.setX(270);

    img_choice2.setY(265);

    img_choice3.setX(270);

    img_choice3.setY(325);

    img_head.setX(150);

    img_head.setY(98);

    img_s_head.setX(215);

    img_s_head.setY(38);

    img_head1.setX(140);

    img_head1.setY(88);

    img_head2.setX(222);

    img_head2.setY(88);

    img_head3.setX(304);

    img_head3.setY(88);

    img_head4.setX(386);

    img_head4.setY(88);

    img_ch1_bg.setX(260);

    img_ch1_bg.setY(180);

    img_ch2_bg.setX(260);

    img_ch2_bg.setY(240);

    img_ch3_bg.setX(260);

    img_ch3_bg.setY(300);

    img_choice1.setCursor(Cursor.HAND);

    img_choice1.setOnMouseClicked(new EventHandler<MouseEvent>(){

      public void handle(MouseEvent e){

        GameFace.run();

      }

    });

    img_choice2.setCursor(Cursor.HAND);

    img_choice2.setOnMouseClicked(new EventHandler<MouseEvent>(){

      public void handle(MouseEvent e){

        ListFace.run();

      }

    });

    img_choice3.setCursor(Cursor.HAND);

    img_choice3.setOnMouseClicked(new EventHandler<MouseEvent>(){

      public void handle(MouseEvent e){

        new LoginFace().start(new Stage());

        primaryStage.close();

      }

    });

    img_ch1_bg.setCursor(Cursor.HAND);

    img_ch1_bg.setOnMouseClicked(new EventHandler<MouseEvent>(){

      public void handle(MouseEvent e){

        GameFace.run();

      }

    });

    img_ch2_bg.setCursor(Cursor.HAND);

    img_ch2_bg.setOnMouseClicked(new EventHandler<MouseEvent>(){

      public void handle(MouseEvent e){

        ListFace.run();

      }

    });

    img_ch3_bg.setCursor(Cursor.HAND);

    img_ch3_bg.setOnMouseClicked(new EventHandler<MouseEvent>(){

      public void handle(MouseEvent e){

        new LoginFace().start(new Stage());

        primaryStage.close();

      }

    });

    Pane pane=new Pane();

    pane.getChildren().addAll(img_bg,img_head1,img_head2,img_head3,img_head4,img_ch1_bg,img_ch2_bg,img_ch3_bg,img_head,img_s_head,img_choice1,img_choice2,img_choice3);

    Scene scene=new Scene(pane,600,400);

    primaryStage.setTitle("狙擊坦克(不區分大小寫版)");

    primaryStage.setWidth(600);

    primaryStage.setHeight(400);

    primaryStage.setResizable(false);

    primaryStage.getIcons().add(char_bg);

    primaryStage.setScene(scene);

    primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){

      public void handle(WindowEvent e){

        System.exit(0);

      }

    });

    primaryStage.show();

  }

}

windows端打字遊戲——功能選擇

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.