mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-07 05:50:54 +07:00
Fixed FPS cap changes
This commit is contained in:
parent
180eb6d1f0
commit
2a6dc573ac
@ -29,6 +29,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
|||||||
|
|
||||||
private long nextFrame;
|
private long nextFrame;
|
||||||
private long beginTime;
|
private long beginTime;
|
||||||
|
private long lastTargetFps = -1;
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
private LoadRenderer loader;
|
private LoadRenderer loader;
|
||||||
|
|
||||||
@ -200,9 +201,12 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
|||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
int targetfps = Core.settings.getInt("fpscap", 120);
|
int targetfps = Core.settings.getInt("fpscap", 120);
|
||||||
|
boolean changed = lastTargetFps != targetfps && lastTargetFps != -1;
|
||||||
boolean limitFps = targetfps > 0 && targetfps <= 240;
|
boolean limitFps = targetfps > 0 && targetfps <= 240;
|
||||||
|
|
||||||
if(limitFps){
|
lastTargetFps = targetfps;
|
||||||
|
|
||||||
|
if(limitFps && !changed){
|
||||||
nextFrame += (1000 * 1000000) / targetfps;
|
nextFrame += (1000 * 1000000) / targetfps;
|
||||||
}else{
|
}else{
|
||||||
nextFrame = Time.nanos();
|
nextFrame = Time.nanos();
|
||||||
|
Loading…
Reference in New Issue
Block a user