龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > JAVA开发 >

Java基于Swing实现的打猎射击游戏代码(8)

时间:2014-11-14 11:09来源:网络整理 作者:网络 点击:
分享到:
public static void main(String args[]) { EventQueue.invokeLater(new Runnable() { public void run() { try { MainFrame frame = new MainFrame(); frame.setVisible(true); frame.start(); } catch (Exception

        public static void main(String args[]) {
                EventQueue.invokeLater(new Runnable() {
                        public void run() {
                                try {
                                        MainFrame frame = new MainFrame();
                                        frame.setVisible(true);
                                        frame.start();
                                } catch (Exception e) {
                                        e.printStackTrace();
                                }
                        }
                });
        }

        /**
         * 启动游戏的方法
         */
        public void start() {
                new PigThread().start();
                new BirdThread().start();
        }

        /**
         * 窗体的鼠标事件监听器
         *
         */
        private final class FrameMouseListener extends MouseAdapter {
                public void mousePressed(final MouseEvent e) {
                        Component at = backgroundPanel.getComponentAt(e.getPoint());
                        if (at instanceof BackgroundPanel) {// 如果点到面板也扣除子弹
                                MainFrame.useAmmo();// 消耗子弹
                        }
                        /*
                         * if (at instanceof BirdLabel) {// 如果点到小鸟 MainFrame.appScore(32);//
                         * 加分 } if (at instanceof PigLabel) {// 如果点到野猪
                         * MainFrame.appScore(11);// 加分 }
                         */
                }
        }

精彩图集

赞助商链接