Search in sources :

Example 1 with MainSurface

use of com.mypro.mainsurface.MainSurface in project Java by bottleleung.

the class AwtMainComponet method main.

public static void main(String[] args) throws Exception {
    Toolkit tool = Toolkit.getDefaultToolkit();
    Dimension d = tool.getScreenSize();
    JFrame frame = new JFrame();
    GamingInfo.getGamingInfo().setGaming(true);
    GamingInfo.getGamingInfo().setScreenWidth(900);
    GamingInfo.getGamingInfo().setScreenHeight(600);
    frame.setSize(GamingInfo.getGamingInfo().getScreenWidth(), GamingInfo.getGamingInfo().getScreenHeight());
    // ȥ�����ڵ�װ��
    frame.setUndecorated(true);
    // frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);//����ָ���Ĵ���װ�η��
    // frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    MainSurface pane = new MainSurface();
    GamingInfo.getGamingInfo().setSurface(pane);
    frame.setContentPane(pane);
    // frame.setAlwaysOnTop(true);
    frame.setVisible(true);
    frame.addMouseListener(new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mousePressed(MouseEvent e) {
            if (GameInitManager.getGameInitManager().isIniting()) {
                return;
            }
            // �ȿ����ֹ������Ƿ�����Ӧ
            if (!LayoutManager.getLayoutManager().onClick(e.getX(), e.getY())) {
                // �����ӵ�
                CannonManager.getCannonManager().shot(e.getX(), e.getY());
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub
        }
    });
    // frame.pack();
    pane.action();
    /**
     * ����һ���߳����첽��ʼ����Ϸ����
     */
    new Thread(new Runnable() {

        public void run() {
            // ʹ����Ϸ��ʼ����������ʼ����Ϸ
            GameInitManager.getGameInitManager().init();
        }
    }).start();
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) JFrame(javax.swing.JFrame) MainSurface(com.mypro.mainsurface.MainSurface) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension)

Aggregations

MainSurface (com.mypro.mainsurface.MainSurface)1 Dimension (java.awt.Dimension)1 Toolkit (java.awt.Toolkit)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 JFrame (javax.swing.JFrame)1