码迷,mamicode.com
首页 > Windows程序 > 详细

windows端打字游戏——功能选择

时间:2017-03-27 11:28:17      阅读:344      评论:0      收藏:0      [点我收藏+]

标签: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端打字游戏——功能选择

标签:show   run   art   icons   getc   list   login   tar   ane   

原文地址:http://www.cnblogs.com/hwb04160011/p/6625144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!