60 fps on Android, how about phone with 120fps

I see some gaming phones now have 120fps, but cocos sets it to default 60 fps?

What exactly is your question, and why would the default FPS be of a concern?

You can set your application to 120FPS if you so wish, but ask yourself why you would want to do this, especially for mobile devices. The higher the FPS, the higher the power drain on the device, and more likely you will see stutter/frame-rate drops if your game takes too long to process the scene before the next render cycle.

2 Likes

In cocos2dxRenderer.java, there are lines like that

private static long sAnimationInterval = (long) (1.0f / 60f * Cocos2dxRenderer.NANOSECONDSPERSECOND);

if (Cocos2dxRenderer.sAnimationInterval <= 1.0f / 60f * Cocos2dxRenderer.NANOSECONDSPERSECOND)
1 Like

You still have not asked a question. What point are you trying to make? What is it that concerns you regarding the 120FPS on certain devices?

Also, what you have posted is not complete and a little misleading, which confuses things even more. How about we post the entire method, including comments:

    @Override
    public void onDrawFrame(final GL10 gl) {
        /*
         * No need to use algorithm in default(60 FPS) situation,
         * since onDrawFrame() was called by system 60 times per second by default.
         */

        if (Cocos2dxRenderer.sAnimationInterval <= 1.0f / 60f * Cocos2dxRenderer.NANOSECONDSPERSECOND) {
            Cocos2dxRenderer.nativeRender();
        } else {
            final long now = System.nanoTime();
            final long interval = now - this.mLastTickInNanoSeconds;
        
            if (interval < Cocos2dxRenderer.sAnimationInterval) {
                try {
                    Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
                } catch (final Exception e) {
                }
            }
            /*
             * Render time MUST be counted in, or the FPS will slower than appointed.
            */
            this.mLastTickInNanoSeconds = System.nanoTime();
            Cocos2dxRenderer.nativeRender();
        }
    }

And also, let’s not ignore this method, which allows you to change the interval:

    public static void setAnimationInterval(float interval) {
        sAnimationInterval = (long) (interval * Cocos2dxRenderer.NANOSECONDSPERSECOND);
    }

I thought the problem is pretty obvious. On a 120fps phone, cocos2dx is restricting to 60 fps.

Of course there is a setAnimatonInterval, but how are we gonna know if it is running at 120fps or not without reading mobile device status.

I respectfully disagree, as there is no obvious problem.

Cocos2d is not restricting anything; you can change the value to whatever you want.

Just because the device display can handle 120fps, does not mean the application must run at 120fps.

Does Android even provide an interface for detecting what the maximum FPS of the display is? If it does, then great, nothing is stopping you from using it and calling setAnimationInterval to set whatever FPS you desire. If it does not, then there is nothing to be done, and it really has nothing to do with the default value that is set in Cocos2d.

The default of 60 FPS is the right choice, since it is the standard for the majority of devices out there, and more than enough for any application to run smoothly.

I don’t see a use case for increasing to 120fps. Thinking about all of my games I don’t feel any of them would benefit from changing to 120fps

What kind of game are you creating. Perhaps an accurate use case would help us to understand.