java手机游戏设计源代码 第10页
附录一 代码
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class lzhhdm extends MIDlet implements CommandListener {
public Display display;
private Image splashLogo;
private boolean isSplash=true;
public Form a;
private Alert alert;
int length;
private MenuScreen menuscreen;
private gameScreen gamescreen;
private Command ok,back;
private byte[] byteInputData;
public lzhhdm()
{
}
protected void startApp() throws MIDletStateChangeException {
display=Display.getDisplay(this);
menuscreen=new MenuScreen(this);
if(isSplash)
{ a=null;
a=new Form("览桥风光V1.0");
ok=new Command("ok",Command.OK,1);
a.append(new StringItem(null,"....."));
a.addCommand(ok);
a.setCommandListener(this);
display.setCurrent(a);
}
}
protected void menuscreenShow()
{
display.setCurrent(menuscreen);
}
protected void menuscreensecond() {
menuscreen=new MenuScreen(this);
MenuScreen.mainmenu[0]="重新开始";//玩完一遍或挂了后在玩一遍 菜单第一项改为 重新开始
display.setCurrent(menuscreen);
}
protected void pauseApp() {}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void helShow()
{ a=null;
a=new Form("览桥风光V1.0");
back=new Command("返回",Command.BACK,1);
a.append(new StringItem(null,"操作方式:上 2 下 8 左 4 右 6 开火 5"));
a.append(new StringItem(null,"弹药数:一次最多打三组"));
a.addCommand(ok);
a.setCommandListener(this);
display.setCurrent(a);
}
protected void renwuShow()
{
a=null;
a=new Form("览桥风光V1.0");
back=new Command("返回",Command.BACK,1);
a.append(new StringItem(null,"游戏名称:览桥风光"));
a.append(new StringItem(null,"版本号:V1.00"));
a.append(new StringItem(null,"制作者:信息电子技术学院01计算机5班 刘泽华 学号:7"));
a.addCommand(ok);
a.setCommandListener(this);
display.setCurrent(a);
}
protected void gameShow()
{ try{
gamescreen=null;
gamescreen=new gameScreen(this);
gamescreen.start();
display.setCurrent(gamescreen);
gamescreen.conti=true;
}catch(Exception exp)
{
System.out.println("dfg");
}
}
public void commandAction(Command arg0, Displayable arg1) {
a=null;
this.menuscreenShow();
}
}
import javax.microedition.lcdui.*;
public class MenuScreen extends Canvas implements Runnable,CommandListener
{
Font lowfont=Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_MEDIUM);
Font highfont=Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_BOLD,Font.SIZE_MEDIUM);
int lowColor=0x000000FF;
int highColor=0x00FF0000;
int highBGColor=0x00CCCCCC;
int width;
boolean co;
int height;
int startHeight;
int spacing=highfont.getHeight()/2;
public static String[] mainmenu={"ÐÂÓÎÏ•","°ïÖú","¹ØÓÚ"};
int menuIndex;
Thread menuThread;
private Command ok=new Command("ok",Command.OK,1);
private lzhhdm midlet;
public MenuScreen(lzhhdm midlet)
{ this.midlet=midlet;
width=getWidth();
height=getHeight();
startHeight=(highfont.getHeight()*mainmenu.length)+((mainmenu.length-1)*spacing);
751com.cn new Thread(this);
menuThread.start();
co=true;
}
public void run()
{
while(co)
{
repaint();
}
}
public void paint(Graphics g)
{
g.setColor(0x00FFFFFF);
g.fillRect(0,0,width,height);
for(int i=0;i<mainmenu.length;i++)
{
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
java手机游戏设计源代码 第10页下载如图片无法显示或论文不完整,请联系qq752018766