关于屏幕切换的问题
我是新手,模仿别人的代码,做了个测试。
新建了一个MIDlet 子类,算是主类把。
然后开始游戏,
Display.getDisplay(this).setCurrent(gameclass);
然后我在这个gameclass里,开始游戏,,游戏有关卡,我想过一关卡,就出现一个“恭喜过关”的屏幕提示,
我大概写了如下
gameclass里,有个success()方法,过关就调用他,然后过几秒就自动进入游戏下一关。
我写了
if(passgate == null)
passgate = new PassGate(this);
Display.getDisplay(parent).setCurrent(passgate); //parent是主类
passgate.start();
然后我在 passgate 类里
public PassGate(GameScreen g)
{
super(false);
gamescreen = g;
}
public void run()
{
long startTime = System.currentTimeMillis();
long timeTaken = System.currentTimeMillis() - startTime;
while(timeTaken<4000L)
{
timeTaken = System.currentTimeMillis() - startTime;
repaint();
}
this.stop();
Display.getDisplay(parent).setCurrent(gameclass);
gamescreen.repaint();
}
synchronized void start()
{
myThread = new Thread(this);
myThread.start();
}
synchronized void stop()
{
myThread = null;
}
public void paint()
{}
现在,提示画面掉出来了,可是不自动反回去啊。请问问题在那里,谢谢。。