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

📄 happypig.java

📁 简单的J2ME手机小游戏 包含游戏的基本;
💻 JAVA
字号:
package com.wqat.SuperPig;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;

/**
 * 游戏主Midlet类
 * 
 * @author wqat
 */

public class HappyPig extends MIDlet
    {

	Displayable dis = null;

	HappyPig midlet = null;
	

	GameOver gameOver;

	GameVectory gameVectory;

	private Display display;

	private Splash splash;

	private Menu menu;

	private Game game;

	private Help help;

	public HappyPig()
	    {
		display = Display.getDisplay(this);
		show(Constant.SPLASH);

	    }

	public void startApp()
	    {

	    }

	public void pauseApp()
	    {
	    }

	public void destroyApp(boolean b)
	    {
	    }

	public void show(int i)
	    {
		switch (i)
		    {
		    case Constant.SPLASH:
			if (splash == null)
			    {
				splash = new Splash(this);
				display.setCurrent(splash);
			    }
			break;
		    case Constant.GAME_OVER :
			    menu=null;
		            game=null;
		           System.gc();
			if (gameOver == null)
			    {
				gameOver = new GameOver(this);
				display.setCurrent(gameOver);
			    }
			break;
		    case Constant.Game_Vectory:
			menu=null;
			game=null;
			if (gameVectory == null)
			    {
				gameVectory= new GameVectory(this);
				display.setCurrent(gameVectory);
			    }
			break;
		    case Constant.MENU:
			splash = null;
			gameVectory =null;
			gameOver = null;

			help = null;
			System.gc();
			if (menu == null)
			    {
				menu = new Menu(this);
				display.setCurrent(menu);
			    }
			break;

		    case Constant.HELP:
			menu = null;
			game = null;
			System.gc();
			if (help == null)
			    {
				help = new Help(this);
				display.setCurrent(help);
			    }
			break;
		    case Constant.GAME:
			menu = null;
			game = null;
			System.gc();
			if (game == null)
			    {
				game = new Game(this);
				this.game.startPlay(1);
				display.setCurrent(game);
				break;
			    }
			break;
		    }

	    }

	/**
         * 退出游戏
         */
	public void quitGame()
	    {
		try
		    {
			destroyApp(true);
		    } catch (Exception e)
		    {
			e.printStackTrace();
		    }
		notifyDestroyed();
	    }

    }

⌨️ 快捷键说明

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