小弟我从别人那找到1份手机代码原代码 但是用WTK运行时候出错,大家帮我看看

jennievict 2007-01-02 09:51:02

//创建日期 2005-4-25
//游戏窗口
//在这个类里检测碰撞。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
//。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
//。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.util.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


class lzhhdm extends MIDlet implements CommandListener
{
}

//=========================================================================

class MenuScreen extends Canvas implements Runnable,CommandListener
{}



//=============================================================================
public class gameScreen extends GameCanvas implements Runnable,CommandListener
{}



WTK2.2 Build编译通过,运行时候提示ClassNotFoundException错误 提示说找不到gameScreen/class 但是我在src目录下找的到gameScreenClass啊 奇怪



...全文
453 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq14923349 2007-01-13
  • 打赏
  • 举报
回复
新手写的吧
huruihappy 2007-01-13
  • 打赏
  • 举报
回复
我也有这份代码 启动类错了
huruihappy 2007-01-13
  • 打赏
  • 举报
回复
``
「已注销」 2007-01-03
  • 打赏
  • 举报
回复
启动类写错了
不要写.class后缀
启动类的地方,直接写类名
另外,你的启动类不止多写了后缀,似乎连名字都写错了
启动类必须是MIDlet的子类
jennievict 2007-01-02
  • 打赏
  • 举报
回复
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);
startHeight=(height-startHeight)/2;
menuIndex=0;
addCommand(ok);
setCommandListener(this);
menuThread =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++)
{
if(i==menuIndex)
{
g.setColor(highBGColor);
g.fillRect(0,startHeight+(i*highfont.getHeight())+spacing,width,highfont.getHeight());
g.setFont(highfont);
g.setColor(highColor);
g.drawString(mainmenu[i],(width-highfont.stringWidth(mainmenu[i]))/2,startHeight+(i*highfont.getHeight())+spacing,20);
}else
{
g.setFont(lowfont);
g.setColor(lowColor);
g.drawString(mainmenu[i],(width-lowfont.stringWidth(mainmenu[i]))/2,startHeight+(i*highfont.getHeight())+spacing,20);
}
}
}
public void keyPressed(int code)
{
if(getGameAction(code)==Canvas.UP&&menuIndex-1>=0)
{
menuIndex--;
}
else if(getGameAction(code)==Canvas.DOWN&&menuIndex+1<mainmenu.length)
{
menuIndex++;
}
}
public void commandAction(Command c,Displayable d)
{
if (c==ok)
{
switch(menuIndex)
{
case 0:
co=false;
midlet.gameShow();

break;
case 1:
midlet.helShow();
break;
case 2:
midlet.renwuShow();
break;

}
}
}
}
jennievict 2007-01-02
  • 打赏
  • 举报
回复
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.util.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


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);
//gamescreen=new gameScreen(this);
menuscreen=new MenuScreen(this);
if(isSplash)
{ System.gc();
a=null;
a=new Form("览桥风光V1.0");
ok=new Command("ok",Command.OK,1);
a.append(new StringItem(null,"1937年7月7日,芦沟桥事变爆发,29军吉星文所部奋起还击,1937年7月17日,蒋中正发表庐山讲话,称“我们东四省失陷,已有了6年之久,续之以塘沽协定,现在冲突地点已到了北平门口的芦沟桥。如果芦沟桥可以受人压迫强占,那么我们百年故都,北方政治文化的中心与军事重镇北平,就要变成沈阳第二!今日的北平,若果变成昔日的沈阳,今日的冀察,亦将成为昔日的东四省。北平若可变成沈阳,南京又何尝不会变成北平!”,“如果战端一开,那就是地无分南北,年无分老幼,无论何人,皆有守土抗战之责,皆应抱定牺牲一切之决心。 1937年8月13日,松沪战役爆发,8月14日,空军第四大队由河南周家口转场浙江览桥,同日八一四览桥空战爆发......"));
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()
{ System.gc();
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()
{ System.gc();
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{
System.gc();
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;
System.gc();
this.menuscreenShow();
}




}
jennievict 2007-01-02
  • 打赏
  • 举报
回复
程序写不下 我慢慢发

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧