鱼
鱼片干子
Unregistered / Unconfirmed
GUEST, unregistred user!
我的applet写在一个线程中,代码如下:
public class TetrisApp extends Applet implements Runnable
{ public void init()
{ String str;
str=getParameter("fpsconfig");
int fps=(str!=null)?Integer.parseInt(str):10;
pause=(fps>0)?(1000/fps):100;
....
}
public void run()
{ long startTime=System.currentTimeMillis();
while(Thread.currentThread()==engine)
{
repaint();
try
{ startTime+=pause;
Thread.sleep(Math.max(0,startTime-System.currentTimeMillis()));
}
catch (InterruptedException e)
{ break;
}
}
}
public void update(Graphics g)
{ .....
}
public void paint(Graphics g)
{ update(g);
}
}
但是动画显示的时候,时快时慢, 请大侠门帮我分析一下.......
小弟谢过了!
public class TetrisApp extends Applet implements Runnable
{ public void init()
{ String str;
str=getParameter("fpsconfig");
int fps=(str!=null)?Integer.parseInt(str):10;
pause=(fps>0)?(1000/fps):100;
....
}
public void run()
{ long startTime=System.currentTimeMillis();
while(Thread.currentThread()==engine)
{
repaint();
try
{ startTime+=pause;
Thread.sleep(Math.max(0,startTime-System.currentTimeMillis()));
}
catch (InterruptedException e)
{ break;
}
}
}
public void update(Graphics g)
{ .....
}
public void paint(Graphics g)
{ update(g);
}
}
但是动画显示的时候,时快时慢, 请大侠门帮我分析一下.......
小弟谢过了!