我正在尝试像这样计算在我的 libGDX 应用程序中传递的时间
float timeSpent= 0;
public void render(){
timeSpent = timeSpent + Gdx.graphics.getDeltaTime();
}
通过上面的代码,我觉得时间几乎是正常速度的两倍
但是如果我像这样直接从java的纳米时间方法中获得增量时间
float prevTime;
float timeSpent = 0;
public void show(){
prevTime = System.nanoTime();
}
public void render(){
float p = System.nanoTime();
timeSpent += (p-prevTime)/1000000000f;
prevTime = p;
}
它似乎工作正常,我知道 libgdx 也从减去纳米时间方法中获得增量时间。
我无法弄清楚我在第一种方法中做错了什么。
谢谢你