我有一个:
@Override
public boolean onTouchEvent(MotionEvent event) {
synchronized (event)
{
try {
Thread.sleep(16);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(event.getAction() == MotionEvent.ACTION_DOWN){
isDown = true;
}else if(event.getAction() == MotionEvent.ACTION_MOVE){
isDown = true;
}else if(event.getAction() == MotionEvent.ACTION_UP){
isDown = false;
}
return true;
}
}
然后在我的MainGame thread
我使用setCharacterPosition();
public void setCharacterPosition(){
if(isDown){
CharacterX += 32;
}
}
但这使我的角色运行得太快了,所以我尝试添加:
Thread.sleep(500);
因为我只希望我的角色每半秒增加 32 个。
它可以工作,但将我的 FPS 降低到 2-3。
我该怎么做?
//西蒙