代码老是出现需要为 class 或 inte易做图ce 哎呀呀
import java.microedition.lcdui;import java.microedition.lcdui.game;
import java.util;
import java.io;
public class nimacanvas extends gameCanvas implements Runnable {
private Display display;
private boolean sleeping;
private long framedelay;
private random rand;
private sprite nimasprite;
private int nimaxspeed, nimayspeed;
public nimacanvas(display d){
super(true);
display = d;
framedelay = 33;
}
public void start(){
display.setcurrentcth(this);
rand = new random();
nimaspeed = nimayspeed = 3;
try {
nimasprite = new spite(image.createimage("/nima.png"));
nimasprite.setposition(0.0);
}
catch (ioexception e) {
system.err.println("failed loading image!");
}
sleeping = false;
thread t = new thread(this);
t.staet();
}
public roid stop(){
sleeping = true;
}
public void run(){
graphis.g = geturaphics();
while(!sleeping)
update();
draw(g);
try{
thread.sleep(framedelay);
}
catch (interruptedexception ie){}
}
}
private void update() {
it(rand.nextInt() % 5 == 0) {
nimaxspeed = math.mim(math.max(Nimaxspend + rand.nextint() 2, -8, 8);
nimayspeed = math.min(math.max(Nimayspend + rand.nextint() 2, -8, 8);
}
nimasprite.move(Nimaxspend,Nimayspeed);
}
private void draw(graphics g){
g.setcolor(0x000000);
g.fillrect(0, 0, getwidth(),getheight());
Nimasprite.paint(g);
flushgraphics();
}
从private void update() {开始报错
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:49: 需要为 class 或 inte易做图ce
private void update() {
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:52: 需要为 class 或 inte易做图ce
nimayspeed = math.min(math.max(Nimayspend + rand.nextint() 2, -8, 8);
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:53: 需要为 class 或 inte易做图ce
}
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:55: 需要为 class 或 inte易做图ce
}
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:58: 需要为 class 或 inte易做图ce
g.fillrect(0, 0, getwidth(),getheight());
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:59: 需要为 class 或 inte易做图ce
Nimasprite.paint(g);
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:60: 需要为 class 或 inte易做图ce
flushgraphics();
^
C:\Users\Administrator\j2mewtk\2.5.2\apps\易做图\src\nimacanvas.java:61: 需要为 class 或 inte易做图ce
}
^
8 错误
com.sun.kvem.ktools.ExecutionException
生成失败
哎呀!是怎么了 求解答!!! --------------------编程问答-------------------- 易做图
这个亮点亮点 --------------------编程问答-------------------- 一般都是少了右花括号导致的,仔细检查大括号的匹配情况 --------------------编程问答-------------------- 我一看你最后就少一个括号 --------------------编程问答-------------------- --------------------编程问答-------------------- ........神兽游戏什么的!呵呵呵 --------------------编程问答-------------------- 额.............括号么!!像{}的是么? --------------------编程问答-------------------- --------------------编程问答-------------------- 呼吁上传源码 --------------------编程问答-------------------- --------------------编程问答-------------------- 遇到同样问题, 已解决。
少{}阿
补充:Java , J2ME