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

📄 helpscreen.java

📁 Java自己做的小游戏
💻 JAVA
字号:
import javax.microedition.lcdui.*;
public class helpScreen
{
	Image helpImg1=null;
	Image helpImg2=null;
	Image pointImg=null;
	boolean upMove=false;
	boolean downMove=false;
	int helpImg2Y=38;
	myCanvas mc=null;
	public helpScreen(myCanvas mc) 
	{
		this.mc=mc;
		initRes();
	}
	public void initRes()
	{
		try
		{
			helpImg1=Image.createImage("/help1.png");
			helpImg2=Image.createImage("/help2.png");
			pointImg=Image.createImage("/point.png");
		}
		catch(Exception e)
		{
			System.out.println("helpScreen图片错误");
			e.printStackTrace();
		}
	}
	public void paint(Graphics g)
	{
		g.setClip(0, 0, mc.getWidth(), mc.getHeight());
		g.setColor(0x000000);
		g.fillRect(0, 0, mc.getWidth(), mc.getHeight());
		g.drawImage(helpImg1, (mc.getWidth()-helpImg1.getWidth())/2, (mc.getHeight()-helpImg1.getHeight())/2, 0);
		if(helpImg2Y+helpImg2.getHeight()>=168)
			g.drawImage(pointImg, (mc.getWidth()-pointImg.getWidth())/2, (mc.getHeight()-helpImg1.getHeight())/2+162, 0);
		g.setClip((mc.getWidth()-helpImg1.getWidth())/2, (mc.getHeight()-helpImg1.getHeight())/2+38, 180, 120);
		g.drawImage(helpImg2, (mc.getWidth()-helpImg1.getWidth())/2, (mc.getHeight()-helpImg1.getHeight())/2+helpImg2Y, 0);
		if(downMove==true&&helpImg2Y+helpImg2.getHeight()>=168)
		{
			helpImg2Y--;
		}
		else if(upMove==true&&helpImg2Y<=38)
		{
			helpImg2Y++;
		}
	}
	public void recycleRes()
	{
		helpImg1=null;
		helpImg2=null;
		pointImg=null;
		mc=null;
	}
	public void processEvent(int key) 
	{
		if(key==0)
		{
			upMove=false;
			downMove=false;
		}
		else if(mc.getGameAction(key)==myCanvas.UP||myCanvas.KEY_NUM2==key)
		{
			upMove=true;
			downMove=false;
		}
		else if(mc.getGameAction(key)==myCanvas.DOWN||myCanvas.KEY_NUM8==key)
		{
			downMove=true;
			upMove=false;
		}
	}
	public void processEvent() 
	{
		myCanvas.state=1;
	}
}

⌨️ 快捷键说明

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