📄 storygameinformationcanvas.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 StoryGameInformationCanvas extends Canvas {
private String cName;// �洢��������
private int gameDoor;// �洢���ڹ���
private String cAppPath;// �洢���·�
private Hashtable gameInfo;//�洢��Ϸ��Ϣ
private Hashtable firstCharacterInfo;//�洢�����Ϣ
private Hashtable secondCharacterInfo;//�洢��ս������Ϣ
private Display display;//��display
private MyMIDLET midlet;//��midlet
private String gameInformation;//�ϲ㴫4�IJ��������Ϣ����Ϸ��Ϣ
//-----------------------------------���췽��------------------------------
public StoryGameInformationCanvas(String gameInformation, Display display,
MyMIDLET midlet) {
this.gameInformation = gameInformation;
this.display = display;
this.midlet = midlet;
cName = gameInformation.substring(0, 8);
gameDoor = Integer.parseInt(gameInformation.substring(8, 9));
cAppPath = gameInformation.substring(9, 10);
if(gameDoor<6){
StoryDataStore dataStore = new StoryDataStore(gameDoor);
gameInfo = dataStore.gameInfo();
gameInfo.put("gameMode", "story");
gameInfo.put("musicVolume", String.valueOf(VolumeRecord.searchRecord()));
secondCharacterInfo = dataStore.secondCharacterInfo();
firstCharacterInfo = new Hashtable();
firstCharacterInfo.put("cName", cName);
firstCharacterInfo.put("gate", new Integer(gameDoor));
firstCharacterInfo.put("cAppPath", cAppPath);
}
}
//-----------------------------------���Ʒ���----------------------------------
public 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));
//��������Ϣ�IJ�ͬ��ͬ
if (gameDoor == 1) {
g.drawString("��һ�� ������̳", width/2-53, height/2-90, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,Font.SIZE_MEDIUM));
g.drawString(" ����˳�������,�������4",width/2-88, height/2-70,Graphics.LEFT | Graphics.TOP);
g.drawString("�ˡ���һ��ѧУ���,�������", width/2-88, height/2-55, Graphics.LEFT| Graphics.TOP);
g.drawString("��ʦ���ǵĽ��������������", width/2-88, height/2-40, Graphics.LEFT | Graphics.TOP);
g.drawString("��ѧϰ����������������˶���", width/2-88, height/2-25, Graphics.LEFT | Graphics.TOP);
g.drawString(" ��������ʦ������֯�Ľ�,",width/2-88, height/2-10,Graphics.LEFT | Graphics.TOP);
g.drawString("���,������ӵ���ѡ���ϸ�ʦ", width/2-88, height/2+5, Graphics.LEFT| Graphics.TOP);
g.drawString("����Ҫ���Ǹ��Ž�������Լ���", width/2-88, height/2+20, Graphics.LEFT| Graphics.TOP);
g.drawString("�赸��", width/2-88, height/2+35, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("ȷ��", width/2-83, height/2+90, Graphics.LEFT | Graphics.TOP);
g.drawString("����", width/2+55, height/2+90, Graphics.LEFT | Graphics.TOP);
} else if (gameDoor == 2) {
g.drawString("�ڶ��� ��ͷ����", width/2-53, height/2-90, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
Font.SIZE_MEDIUM));
g.drawString(" ��ı��ֱ�ʦ���������,��", width/2-88, height/2-70, Graphics.LEFT | Graphics.TOP);
g.drawString("Ϊ���е�һԱ.��Ŭf��wϰ�š�", width/2-88, height/2-55, Graphics.LEFT | Graphics.TOP);
g.drawString(" ���,�ص��˼ҡ�һ������,��", width/2-88, height/2-40, Graphics.LEFT | Graphics.TOP);
g.drawString("�ڽ���ɢ��,��Ȼ������Զ������", width/2-88, height/2-25, Graphics.LEFT| Graphics.TOP);
g.drawString("���ڶ��衣�������Ǽ��α��ݺ�,", width/2-88, height/2-10, Graphics.LEFT | Graphics.TOP);
g.drawString("���̲�ס��ǰ��ս��", width/2-88, height/2+5, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("ȷ��", width/2-83, height/2+90, Graphics.LEFT | Graphics.TOP);
g.drawString("����", width/2+55, height/2+90, Graphics.LEFT | Graphics.TOP);
} else if (gameDoor == 3) {
g.drawString("������ һ�����", width/2-53, height/2-90, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
Font.SIZE_SMALL));
g.drawString(" ��Ľ��豻��Щͬ�����Ͽ�,", width/2-88, height/2-70, Graphics.LEFT | Graphics.TOP);
g.drawString("����������������ǵ���֯,һ��", width/2-88, height/2-55, Graphics.LEFT | Graphics.TOP);
g.drawString("���μ��н������", width/2-88, height/2-40, Graphics.LEFT | Graphics.TOP);
g.drawString(" ��ͬ��İ�����㾫�ĵ���", width/2-88, height/2-25, Graphics.LEFT | Graphics.TOP);
g.drawString("��,����輼���˺ܴ����ߡ���", width/2-88, height/2-10, Graphics.LEFT| Graphics.TOP);
g.drawString("�ڵ��˱������һ�졢���ڵ���", width/2-88, height/2+5, Graphics.LEFT | Graphics.TOP);
g.drawString("�������̨����һ��,����������", width/2-88, height/2+20, Graphics.LEFT | Graphics.TOP);
g.drawString("�����ֿ�ʼ�˵ı��ݡ�", width/2-88, height/2+35, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("ȷ��", width/2-83, height/2+90, Graphics.LEFT | Graphics.TOP);
g.drawString("����", width/2+55, height/2+90, Graphics.LEFT | Graphics.TOP);
} else if (gameDoor == 4) {
g.drawString("������ ���ָ���", width/2-53, height/2-90, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
Font.SIZE_MEDIUM));
g.drawString(" ��ı�����������е���ί", width/2-88, height/2-70, Graphics.LEFT | Graphics.TOP);
g.drawString("����,���������ʤ��", width/2-88, height/2-55, Graphics.LEFT | Graphics.TOP);
g.drawString(" ����,һ��ȫ��ְҵ�Ľ����", width/2-88, height/2-40, Graphics.LEFT | Graphics.TOP);
g.drawString("��ʼ��,������ͬ�鱨��μ�", width/2-88, height/2-25, Graphics.LEFT| Graphics.TOP);
g.drawString("��ʡ��Ԥ��,��һ·���ն��,���", width/2-88, height/2-10, Graphics.LEFT | Graphics.TOP);
g.drawString("�˾���,ȫ�������������ǰ��", width/2-88, height/2+5, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("ȷ��", width/2-83, height/2+90, Graphics.LEFT | Graphics.TOP);
g.drawString("����", width/2+55, height/2+90, Graphics.LEFT | Graphics.TOP);
} else if (gameDoor == 5) {
g.drawString("������ Ц����̳", width/2-53, height/2-90, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
Font.SIZE_MEDIUM));
g.drawString(" ��Ȼ���Ӳ��Ǻ�����,���㻹", width/2-88, height/2-70, Graphics.LEFT | Graphics.TOP);
g.drawString("��ƾ���Լ������˽�����ȫ���", width/2-88, height/2-55, Graphics.LEFT | Graphics.TOP);
g.drawString("�ܾ���", width/2-88, height/2-40, Graphics.LEFT | Graphics.TOP);
g.drawString(" ȫ���������Ƽ�,Ӯ�ñ���", width/2-25, height/2-70, Graphics.LEFT | Graphics.TOP);
g.drawString("Ҳ�쳣�ļ��ѡ���ƾ�������ʵ", width/2-88, height/2-10, Graphics.LEFT| Graphics.TOP);
g.drawString("f������������ľ���,�õ�", width/2-88, height/2+5, Graphics.LEFT | Graphics.TOP);
g.drawString("��������ͬ�������Ļ�ᡣ", width/2-88, height/2+20, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("ȷ��", width/2-83, height/2+90, Graphics.LEFT | Graphics.TOP);
g.drawString("����", width/2+55,height/2+90, Graphics.LEFT | Graphics.TOP);
} else if(gameDoor==6){
g.drawString("� ��������", width/2-53, height/2-90, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
Font.SIZE_MEDIUM));
g.drawString(" ���еĹ��ڶ����������ǵ�,", width/2-88, height/2-70, Graphics.LEFT | Graphics.TOP);
g.drawString("����}���˹�ͬ����,��Ϊ��̳��", width/2-88, height/2-55, Graphics.LEFT | Graphics.TOP);
g.drawString("����", width/2-88, height/2-40, Graphics.LEFT | Graphics.TOP);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("����", width/2+55, height/2+90, Graphics.LEFT | Graphics.TOP);
}
}
//--------------------------------��Ӧ����-----------------------------------
public void keyPressed(int keycode) {
//�ж��û��Ƿ�ͨ��
if(gameDoor<6){
if (keycode == KEY_NUM5 || keycode == -5||keycode==-6) {
//����������Ϸ
midlet.startCompetition(gameInfo, firstCharacterInfo,
secondCharacterInfo);
} else if(keycode==-7){
//��������˵�
MyCanvas myCanvas = new MyCanvas(midlet);
myCanvas.setFullScreenMode(true);
myCanvas.setWhichmodel(5);
myCanvas.setUsernameInformation(gameInformation);
display.setCurrent(myCanvas);
}
}else{
if (keycode == KEY_NUM5 || keycode == -5||keycode==-7) {
//��������˵�
MyCanvas myCanvas = new MyCanvas(midlet);
myCanvas.setFullScreenMode(true);
myCanvas.setWhichmodel(5);
myCanvas.setUsernameInformation(gameInformation);
display.setCurrent(myCanvas);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -