j2me启动一个动画界面,三秒后跳转到高级界面,但老是跳不过去,帮忙看下这个类有没问题呀。谢谢大虾们
importjavax.microedition.lcdui.Graphics;importjavax.microedition.lcdui.Image;importja...
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.Sprite;
//********跳动的动画类****************//
public class Donghua extends GameCanvas implements Runnable{
private Image img;
private Sprite sp1;
private Graphics gra;
private boolean RUN = true;
private ClientMIDlet4 f;
private long lastTime;
private Thread th = new Thread();
public Donghua(ClientMIDlet4 d){
super(true);
this.f=d;
try{
img = Image.createImage("/QGG.png");
sp1 = new Sprite(img,img.getWidth()/4,img.getHeight());
gra = this.getGraphics();
}catch(Exception ex){
ex.printStackTrace();
}
sp1.setPosition(72, 160);
th.start();
System.out.println("D");
}
public void run() {
lastTime=System.currentTimeMillis();
while(RUN){
sp1.paint(gra);
this.flushGraphics();
sp1.nextFrame();
try{
Thread.currentThread();
Thread.sleep(500);
}catch(Exception ex){
}
if(System.currentTimeMillis()-lastTime>3000){
RUN=false;
}
f.changeForm("Chat");
}
}
} 展开
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.Sprite;
//********跳动的动画类****************//
public class Donghua extends GameCanvas implements Runnable{
private Image img;
private Sprite sp1;
private Graphics gra;
private boolean RUN = true;
private ClientMIDlet4 f;
private long lastTime;
private Thread th = new Thread();
public Donghua(ClientMIDlet4 d){
super(true);
this.f=d;
try{
img = Image.createImage("/QGG.png");
sp1 = new Sprite(img,img.getWidth()/4,img.getHeight());
gra = this.getGraphics();
}catch(Exception ex){
ex.printStackTrace();
}
sp1.setPosition(72, 160);
th.start();
System.out.println("D");
}
public void run() {
lastTime=System.currentTimeMillis();
while(RUN){
sp1.paint(gra);
this.flushGraphics();
sp1.nextFrame();
try{
Thread.currentThread();
Thread.sleep(500);
}catch(Exception ex){
}
if(System.currentTimeMillis()-lastTime>3000){
RUN=false;
}
f.changeForm("Chat");
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询