⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twinscanvas.java

📁 这是一个连连看的JAVA代码
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Twins;import javax.microedition.lcdui.*;import javax.microedition.lcdui.game.GameCanvas;/** * @author Null */public class TwinsCanvas extends GameCanvas implements Runnable,CommandListener {    boolean suspend = false;    private Twins Game;        public boolean IsNewGame;    private Command cmdNewGame;    private Command cmdShowTips;    private Command cmdBack;    private Command cmdExit;    private Command cmdCancel;    public frmMain Root;    Thread thread = null;        public TwinsCanvas()    {        super(false);        this.setFullScreenMode(true);        try {	    // Set up this canvas to listen to command events	    setCommandListener(this);	    // Add the Exit command            cmdNewGame=new Command("新游戏", Command.EXIT, 1);            cmdShowTips=new Command("提示", Command.EXIT, 2);            cmdBack=new Command("返回", Command.EXIT, 3);            cmdExit=new Command("退出", Command.EXIT, 4);            cmdCancel=new Command("取消", Command.EXIT, 5);	    addCommand(cmdNewGame);            addCommand(cmdShowTips);            addCommand(cmdBack);            addCommand(cmdExit);            addCommand(cmdCancel);                    } catch(Exception e) {            e.printStackTrace();        }        Game=new Twins();        Game.Root=this;    }    public void paint(Graphics g)    {        Game.Flush(g);    }        protected void showNotify()    {        //random = new Random();        thread = new Thread(this);        thread.start();        if(IsNewGame)        {            Game.NewGame();            IsNewGame=false;        }        //Game.NewGame();        //System.out.println("33893389");    }    // When the game canvas is hidden, stop the thread.    protected void hideNotify()    {        thread=null;    }    protected  void keyPressed(int keyCode)     {        //System.out.println(keyCode);        Game.KeyPress(keyCode);    }            protected  void pointerPressed(int x, int y) {     Game.Press(x,y);    }        public void commandAction(Command cmd, Displayable arg1) {	    if(cmd==cmdNewGame)            {                Game.DoCommand(0);            }else if(cmd==cmdShowTips)            {                Game.DoCommand(1);            }else if(cmd==cmdBack)            {                Game.DoCommand(2);            }else if(cmd==cmdExit)            {                Root.exitMIDlet();            }else if (cmd==cmdCancel)            {                            }    }    //控制屏幕刷新    public void run() {        while (thread != null)        {            repaint();            try {                                Thread.sleep(200);            } catch (InterruptedException ex) {                ex.printStackTrace();            }        }    }         public void stop()    {        if (thread != null)        {            //thread.;            thread = null;        }    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -