gameover.java

来自「自己做的一个JAVA射击小游戏!可以上真机玩的!」· Java 代码 · 共 63 行

JAVA
63
字号
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class gameOver 
{   
	AcCV ac=null;
	Image gameOverImg=null;
	public gameOver(AcCV ac) 
	{
		this.ac=ac;
		try
		{
		gameOverImg=Image.createImage("/gameover.png");
		}
		catch(Exception e)
		{
			System.out.println("gameOver图片错误");
			e.printStackTrace();
		}
	}
	public void paint(Graphics g)
	{
		g.setClip(0, 0, ac.getWidth(), ac.getHeight());
		g.setColor(0x000000);
		g.fillRect(0, 0, ac.getWidth(), ac.getHeight());
		g.drawImage(gameOverImg,(ac.getWidth()-gameOverImg.getWidth())/2, (ac.getHeight()-gameOverImg.getHeight())/2, 0);
		if(ac.num>0&&ac.num<300){
		Font font=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
		g.setFont(font);
		g.setColor(250,0,0);
		g.drawString("你好搓啊,", (ac.getWidth()-gameOverImg.getWidth())/2+50, (ac.getHeight()-gameOverImg.getHeight())/2+90, 0);
		g.drawString("才打了这点分数!", (ac.getWidth()-gameOverImg.getWidth())/2+50, (ac.getHeight()-gameOverImg.getHeight())/2+105, 0);
		g.drawString(""+ac.num, (ac.getWidth()-gameOverImg.getWidth())/2+65, (ac.getHeight()-gameOverImg.getHeight())/2+76, 0);
	   }
		if(ac.num>300&&ac.num<900){
		Font font=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
		g.setFont(font);
		g.setColor(0,0,250);
		g.drawString("没到一定分数,", (ac.getWidth()-gameOverImg.getWidth())/2+50, (ac.getHeight()-gameOverImg.getHeight())/2+90, 0);
		g.drawString("第四关进不去可惜!", (ac.getWidth()-gameOverImg.getWidth())/2+50, (ac.getHeight()-gameOverImg.getHeight())/2+105, 0);
		g.drawString(""+ac.num, (ac.getWidth()-gameOverImg.getWidth())/2+65, (ac.getHeight()-gameOverImg.getHeight())/2+76, 0);
		}
	   if(ac.num>900){
		Font font=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
		g.setFont(font);
		g.setColor(0,250,0);
		g.drawString("恭喜你全部,", (ac.getWidth()-gameOverImg.getWidth())/2+50, (ac.getHeight()-gameOverImg.getHeight())/2+90, 0);
		g.drawString("过关可以的!", (ac.getWidth()-gameOverImg.getWidth())/2+50, (ac.getHeight()-gameOverImg.getHeight())/2+105, 0);
		g.drawString(""+ac.num, (ac.getWidth()-gameOverImg.getWidth())/2+65, (ac.getHeight()-gameOverImg.getHeight())/2+76, 0);
	}
	}
	public void recycleRes()
	{
		gameOverImg=null;
		ac=null;
	}
	public void processEvent() 
	{   
		AcCV.state=1;
		ac.eRun=true;
		
	}
}

⌨️ 快捷键说明

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