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

📄 freegameinformationcanvas.java

📁 一款模仿劲舞团的手机游戏
💻 JAVA
字号:


import java.util.Hashtable;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

/**
 * @author trojan
 * 
 * ����ģʽ��Canvas
 */
public class FreeGameInformationCanvas extends Canvas{
		
	private String gameInformation;//������Ϣ

	private Display display;//��display
	
	private MyMIDLET midlet;//��midlet
	
	private String picture;//�洢��ѡ��ij���
	
	private String music;//�洢��ѡ�������
	
	private String cName;//�洢���UserName
	
	private String cAppPath;//�洢�����װ
	
	private Hashtable gameInfo;//�洢��Ϸ��Ϣ

	private Hashtable firstCharacterInfo;//�洢�����Ϣ

	private Hashtable secondCharacterInfo;//�洢��ս������Ϣ

	//-------------------------------���췽������ʼ������Ϣ��---------------------------
	public FreeGameInformationCanvas(String gameInformation, Display display,
			MyMIDLET midlet,String picture,String music){
		this.display=display;
		this.gameInformation=gameInformation;
		this.midlet=midlet;
		this.picture=picture;
		this.music=music;
		cName = gameInformation.substring(0, 8);
		cAppPath = gameInformation.substring(9, 10);
		firstCharacterInfo=new Hashtable();
		secondCharacterInfo=new Hashtable();
		firstCharacterInfo.put("cName", cName);
		firstCharacterInfo.put("cAppPath", cAppPath);
		secondCharacterInfo.put("cName", "Trojan");
		secondCharacterInfo.put("cAppPath", "3");
		FreeDataStore freeDataStore=new FreeDataStore(this.music,this.picture);
		gameInfo=freeDataStore.gameInfo();
		gameInfo.put("gameMode", "free");
		gameInfo.put("musicVolume", String.valueOf(VolumeRecord.searchRecord()));
	}
	
	//---------------------------------���Ʒ���------------------------------------------
	protected void paint(Graphics g) {
		int width=this.getWidth();
		int height=this.getHeight();
		Font font = Font.getDefaultFont();
		g.setFont(font);
		g.setColor(0x00000000);
		g.fillRect(0, 0, width, height);
		g.setColor(255, 255, 255);
		g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
				Font.SIZE_LARGE));
		g.drawString("��ѡ����:", width/2-88, height/2-50, Graphics.LEFT | Graphics.TOP);
		//���ѡ��ij�������ʾ�������
		if(picture.equals("0")){
			g.drawString("�Լ�С��", width/2-18, height/2-50, Graphics.LEFT | Graphics.TOP);
		}else if(picture.equals("1")){
			g.drawString("ѧУ��԰", width/2-18, height/2-50, Graphics.LEFT | Graphics.TOP);
		}else if(picture.equals("2")){
			g.drawString("��ͷ��", width/2-18, height/2-50, Graphics.LEFT | Graphics.TOP);
		}else if(picture.equals("3")){
			g.drawString("�����չ�", width/2-18, height/2-50, Graphics.LEFT | Graphics.TOP);
		}else if(picture.equals("4")){
			g.drawString("ʡ�����̨", width/2-18, height/2-50, Graphics.LEFT | Graphics.TOP);
		}else if(picture.equals("5")){
			g.drawString("��������ǰ", width/2-18, height/2-50, Graphics.LEFT | Graphics.TOP);
		}
		g.drawString("��ѡ����:", width/2-88, height/2-10, Graphics.LEFT | Graphics.TOP);
		//���ѡ������֣���ʾ������Ϣ
		if(music.equals("0")){
			g.drawString("���Ǵ�˵", width/2-18, height/2-10, Graphics.LEFT | Graphics.TOP);
		}else if(music.equals("1")){
			g.drawString("���t���ҵ���", width/2-18, height/2-10, Graphics.LEFT | Graphics.TOP);
		}else if(music.equals("2")){
			g.drawString("����", width/2-18, height/2-10, Graphics.LEFT | Graphics.TOP);
		}else if(music.equals("3")){
			g.drawString("���²���", width/2-18, height/2-10, Graphics.LEFT | Graphics.TOP);
		}else if(music.equals("4")){
			g.drawString("���������", width/2-18, height/2-10, Graphics.LEFT | Graphics.TOP);
		}else if(music.equals("5")){
			g.drawString("�Բ���,�Ұ���", width/2-18, height/2-10, Graphics.LEFT | Graphics.TOP);
		}
		g.drawString("ȷ��", width/2-83, height/2+90, Graphics.LEFT | Graphics.TOP);
		g.drawString("����", width/2+55, height/2+90, Graphics.LEFT | Graphics.TOP);
		
		
	}
	
	//--------------------------------��Ӧ����--------------------------------------
	public void keyPressed(int keycode) {
		if(keycode==-6||keycode == KEY_NUM5 || keycode == -5){
			//����������Ϸ
			midlet.startCompetition(gameInfo, firstCharacterInfo,
					secondCharacterInfo);
		}else if(keycode==-7){
			//��������˵�
			MyCanvas myCanvas = new MyCanvas(midlet);
			myCanvas.setFullScreenMode(true);
			myCanvas.setWhichmodel(6);
			myCanvas.setUsernameInformation(gameInformation);
			display.setCurrent(myCanvas);
		} 
	}
}

⌨️ 快捷键说明

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