Hello,
I want to lower the frame rate in cocos2d-x 3.0 to 30 fps. On iOS it works just fine but when it comes to android the game is still running at ~60 fps instead of the 30 fps, which I set in the AppDelegate.
Is there anything I must do to get it work on android?
Look on forum. On android code responsible for FPS is comented. Check file Cocos2dxRenderer.java ? Look for it.
/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java
My look like this:
@Override
public void onDrawFrame(final GL10 gl) {
long lastTime = System.currentTimeMillis();
lastTime = System.currentTimeMillis() - startTime;
if (lastTime < Cocos2dxRenderer.sAnimationInterval) {
try {
Thread.sleep(Cocos2dxRenderer.sAnimationInterval - lastTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
startTime = System.currentTimeMillis();
Cocos2dxRenderer.nativeRender();
}
And Cocos2dxRenderer.sAnimationInterval is defined as this:
private static long sAnimationInterval = (long) (1.0 / 60 * Cocos2dxRenderer.NANOSECONDSPERSECOND);
Thanks for your help, but in cocos2d-x 3.0 there is no Cocos2dxRenderer.java thats why i can’t use the solution for this problem.
Hi guys,
I’m just starting my first Android port and I’ve run into the same problem. I’m using Cocos2d-x 3 frame rate isn’t being limited to 30 like it should be.
As Sebastian says, the Cocos2dxRenderer.java doesn’t work as the file doesn’t exist on Cocos2d-x 3.
Has anyone found a work around for this yet?
Thanks!