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

📄 loading.java

📁 《剑魂》经典的手机RPG源代码
💻 JAVA
字号:
import javax.microedition.lcdui.*;
import java.lang.*;
import com.nokia.mid.ui.*;
/*定义载入画面
*/
public class Loading extends FullCanvas implements Runnable
{
	public static Thread ld;//定义Loading的进程
	private int type;
	private Image com,com2,intro,text,sword,light;//定义载入时的图片
	private int x;
	private int y;
	int lightx;
	String story="故事简介:在一个安静的小山村里面,生活着一些勤劳勇敢的村民,他们每天的生活都是忙忙碌碌的,但是不就以前这安静的生活被彻底的打乱了,村民门发现周围的事物都变的很可怕,每个人的表情也是很奇怪,原来是在村子中连续发生了几起命案,而凶手就是一些不知名的妖怪,他们的手段残忍,竹庆是一个勇敢的青年,他的父亲也被妖怪所害,他决定替父报仇,消灭那群可恶的妖怪,他能成功吗?";
	String end="游戏胜利:所有的怪都已经不复存在了,我们勇敢的年轻人可以回去家乡报喜了,村庄又恢复了往常的宁静,村民们又过上了幸福而快乐的生活!请关注后续版本";
	private int proid;
	int row;
	public static boolean running;
	public static Font myfont=Font.getFont(0,0,8);
	/*参数i表示Loading的类型,1是新游戏的Loading,0是读取进度,2是移动Logo*/
	public Loading(int i)
	{
		running=true;
		this.type=i;
		y=50;
		proid=0;
		row=(story.length()-1)/10;
		//myfont=Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_SMALL);
		if(i==2)
		{
			try
			{
				com=Image.createImage("/Loading/com.png");
				com2=Image.createImage("/Loading/comm.png");
				intro=Image.createImage("/introBg.png");
				text=Image.createImage("/jianhun.png");
			}
			catch(java.io.IOException e)
			{
			}
		}
		else
		if(i==1||i==0)
		{
			lightx=0;
			try
			{
				intro=Image.createImage("/introBg.png");
				sword=Image.createImage("/sword.png");
				light=Image.createImage("/light.png");
			}
			catch(Exception e)
			{
			}
		}
	}
	public void paint(Graphics g)
	{	
		if(type==2)
		{
			g.setColor(-1);
			g.fillRect(0,0,176,208);				
			if(x<10)
			g.drawImage(com,24,40,0);
			else
			if(x<20)
			g.drawImage(com2,24,40,0);
			else
			if(x<=30)
			{
	    	g.drawImage(intro,0,0,0);
	    	g.drawImage(text,108-text.getWidth()/2,104-text.getHeight()/2,0);			
			}
			if(x==30)
			{
				GM.mg.show(MG.gm);
				MG.gm.start();
				MG.ld=null;
			}				
			return;
		}
		else
		if(type==1)
		{
			g.drawImage(intro,0,0,0);
			if(x<50)
			{
				g.drawImage(sword,88,80,17);
				g.drawImage(light,40+lightx*2,65,0);
				GM.sc.drawStringShadow(g,0,0,-1,"载入中",88,40,17);
				lightx+=1;
			}
			else
			if(x<140)
			{
				g.setColor(255,255,255);
				g.setClip(0,31,176,144);
				for(int i=0;i<=row;i++)
				{
					if((i+1)*10<story.length())
					GM.sc.drawStringShadow(g,0,0,-1,story.substring(i*10,(i+1)*10),88,31+i*18+y,17);
					else
					GM.sc.drawStringShadow(g,0,0,-1,story.substring(i*10,story.length()),88,31+i*18+y,17);
				}
				g.setClip(0,0,176,208);		
			}	
			if(x==140)
			{
				GM.mgc=new MGC();
				GM.mgc.ge();
				GM.ld=null;
				GM.mg.show(GM.mgc);
				GM.mgc.map=GM.sc.createPlayer("/1.mid",1000);
				if(GM.playOn)
				{
					GM.sc.playSound(GM.mgc.map);
				}					
				MG.showGame=true;
			}	
			return;
		}
		else
		if(type==0)
		{
			g.drawImage(intro,0,0,0);
			if(x<50)
			{
				g.drawImage(sword,88,80,17);
				g.drawImage(light,40+lightx*2,65,0);
				GM.sc.drawStringShadow(g,0,0,-1,"载入中",88,40,17);
				lightx+=1;
			}
			else
			if(x==50)
			{
				GM.mg.show(GM.mgc);
				MG.showGame=true;
				GM.mgc.map=GM.sc.createPlayer("/1.mid",1000);
				if(GM.playOn)
				{
					GM.sc.playSound(GM.mgc.map);
				}
			}	
			return;
		}
//		if(type!=3)
//		{
//			if(x<11)
//			{
//				if(type!=2)
//				{
//					g.setColor(255,255,255);
//					g.drawString("载入中.....",45,50,0);
//				}
//				else
//				{
//					g.setColor(-1);
//					g.fillRect(0,0,176,208);
//					g.drawImage(com,88,40,17);       
//				}
//			}
//			else
//			if(type==1)
//			{	
//				//addCommand(skip);
//				//setCommandListener(this);
//				if(x<80)
//				{
//					g.setColor(255,255,255);
//					for(int i=0;i<=row;i++)
//					{
//						if((i+1)*10<story.length())
//						g.drawString(story.substring(i*10,(i+1)*10),88,i*18+y,17);
//						else
//						g.drawString(story.substring(i*10,story.length()),88,i*18+y,17);
//					}
//					g.setColor(0);
//					g.fillRect(0,0,19,208);
//					g.fillRect(157,0,19,208);
//					g.setColor(0xffffff);
//					for(int ii=0;ii<208/15;ii++)
//					{
//						g.fillArc(5,ii*15+5,10,10,0,360);
//						g.fillArc(161,ii*15+5,10,10,0,360);
//					}		
//				}
//				else
//				{
//					System.out.println("start");
//					GM.mgc=new MGC();
//					GM.mgc.ge();
//					GM.ld=null;
//					GM.mg.show(GM.mgc);
//					if(GM.playOn)
//					{
//						GM.mgc.map=GM.sc.createPlayer("/1.mid",1000);
//						GM.sc.playSound(GM.mgc.map);
//					}					
//					MG.showGame=true;
//				}
//			}
//			else
//			{
//				if(x<30)
//				{
//					if(type!=2)
//					{
//						g.setColor(255,255,255);
//						g.drawString("载入中.....",45,50,0);
//					}
//					else
//					{
//						    g.setColor(-1);
//						    g.fillRect(0,0,176,208);
//					  	  if(x<20)
//					  	  {
//										g.drawImage(com2,88,40,17);
//						    }
//						    else
//						    {
//						    	g.drawImage(intro,0,0,0);
//						    	Image image=GM.sc.createARGBImage(text,0xd2000000+x*0x03000000);
//						    	g.drawImage(image,88-image.getWidth()/2,104-image.getHeight()/2,0);
//						    }
//					}
//				}
//				else		
//				{
//					GM.ld=null;
//					if(type==2)
//					{
//						GM.mg.show(MG.gm);
//						MG.gm.start();
//						MG.ld=null;
//					}
//					else
//					{
//						GM.mg.show(GM.mgc);
//						MG.showGame=true;
//						if(GM.playOn)
//						{
//							GM.mgc.map=GM.sc.createPlayer("/1.mid",1000);
//							GM.sc.playSound(GM.mgc.map);
//						}
//					}						
//					intro=null;			
//				}
//			}
//		}
//		else
//		{
//			//addCommand(skip);
//			//setCommandListener(this);			
//			if(x<60)
//			{
//				g.setColor(255,255,255);
//					for(int i=0;i<row;i++)
//					{
//						if((i+1)*10<end.length())
//						g.drawString(end.substring(i*10,(i+1)*10),88,i*18+y,17);
//						else
//						g.drawString(end.substring(i*10,story.length()),88,i*18+y,17);
//					}
//			}
//			else
//			{
//				GM.cI();
//				GM.mg.show(MG.gm);
//			}
//		}		
	}
	public void run()
	{
		x=0;
		ld=new Thread(MG.gm.ld);
		int limitX=0;
		if(type==0)
		limitX=50;
		else
		if(type==1)
		limitX=140;
		else
		if(type==2)
		limitX=30;
		while(x<=limitX)
		{
			try
			{
				if(running)
				{
					switch(type)
					{
						case 0://读取存档
						if(x==1)
						{
							GM.mgc=null;
							//System.gc();								
							MGC.sl=0;
							MGC.cI();//导入图形
						}
						else
						if(x==5)
						{
							GM.mgc=new MGC();
							GM.mgc.ge();
						}
						else
						if(x==7)
						{
							System.out.println("in");
							SA s=new SA();
							s.r();
							s=null;
							System.out.println("out");
						}
						else
						if(x==10)
						{
							GM.mgc.lm=GM.mgc.le*GM.mgc.le+10*GM.mgc.le+60;
							GM.mgc.mm=20*GM.mgc.le+20;
							GM.mgc.d=5*GM.mgc.le+2;
							GM.mgc.D=GM.mgc.d;
							if(GM.mgc.dlg[0])
							{
								GM.mgc.me=false;
								GM.mgc.dlgpic=null;
								MGC.x=MGC.startx[MGC.sl];
								MGC.y=MGC.starty[MGC.sl];
							}
							else
							{
								GM.mgc.me=true;
								MGC.x=384;
								MGC.y=304;
							}
							if(MGC.x>=MGC.w/2)
							{
								if(MGC.x<=MGC.W[MGC.sl]*16-MGC.w/2)
								MGC.x0=MGC.x-MGC.w/2;
								else
								MGC.x0=MGC.W[MGC.sl]*16-MGC.w;
							}
							else
							MGC.x0=0;
							if(MGC.y>=MGC.h/2)
							{
								if(MGC.y<=MGC.H[MGC.sl]*16-MGC.h/2)
								MGC.y0=MGC.y-MGC.h/2;
								else
								MGC.y0=MGC.H[MGC.sl]*16-MGC.h;
							}
							else
							MGC.y0=0;
							GM.mgc.repaint();
						}													
						break;
						case 1://开始新游戏
						if(x==1)
						{
							GM.mgc=null;
							//System.gc();								
							MGC.sl=0;
							MGC.cI();//导入图形
						}
						else
						if(x>50)
						y-=4;				
						break;
						case 3://游戏结束
						y-=4;
						break;
						default:
						break;
					}					
					repaint();
					x++;
				}
				if(type==2)
				Thread.sleep(100);//0.45秒后载入过程结束	
				else
				if(type==1||type==0)
				Thread.sleep(50);
			}
			catch(java.lang.InterruptedException ie)
			{
			}
		}
		running=false;
		return;	
	}
}				

⌨️ 快捷键说明

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