rainbow.java

来自「J2ME的游戏原代码!希望能帮助有需要帮助的师兄弟们!」· Java 代码 · 共 76 行

JAVA
76
字号
// colorbugs
// coded by Tota



import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

 //Midp class
public class rainbow extends MIDlet implements CommandListener {

	private Display display;
	private Command exit;
	private MyCanvas canvas;
   	private Command helpCommand;
   	/* Start	Addition		17-03-2003		for external events	*/
   	private boolean firstTime;
   	/* End		Addition		17-03-2003	*/

	public rainbow(){
		display = Display.getDisplay(this);
		exit=new Command("Exit",Command.EXIT,1);
		helpCommand =new Command("Help",Command.SCREEN,2);

	}

	/*  start */
	public void startApp(){

	   	/* Start	Modified		17-03-2003		for external events	*/
		if(!firstTime){
			canvas=new MyCanvas();
			canvas.addCommand(exit);
			canvas.addCommand(helpCommand);
			canvas.setCommandListener(this);
			display.setCurrent(canvas);
			firstTime = true;
		}else {
			canvas.onoff = true;
		}
	   	/* End		Modified		17-03-2003	*/

	}

	public void pauseApp()
	{
		/* Start	Addition	20-03-2003	*/
		canvas.onoff = false;
		/* End	Addition	20-03-2003	*/
	}

		public void destroyApp(boolean unconditional)
	{
	}

	public void commandAction(Command c,Displayable s)
	{
		if (c==exit)
		{
			destroyApp(false);
			notifyDestroyed();
		}else if(c== helpCommand){
			/* Start	Modified		17-03-2003	for help text	*/
			Alert alert=new Alert("Help","Use the joystick to move the cursor."+
							" Push the joystick to generate the rainbow.",
							null,AlertType.INFO);
			/* End	Modified		17-03-2003	*/

			//Alert alert=new Alert("help","use joystick to move a cursor and press (push) to generate rainbow",null,AlertType.INFO);
			alert.setTimeout(Alert.FOREVER);
			display.setCurrent(alert);

		}
	}
}

⌨️ 快捷键说明

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