A small method about cocos2dx frame rate compensation

1. Use setAnimationInterval( 1.0  /15 ) ? Found that running on Android does not work! Ok, then go to the official Github [ https://github.com/cocos2d/cocos2d-x/blob/1643c29a000d2e6720a2eb36e118ed7461487473/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java ] to update the code Update Cocos2dxRenderer.java , and then change the 60 in +private static long sAnimationInterval = ...; to the frame rate you need , this code is now the beta code of cocos2dx 3.3 2. Do you want to use

setAnimationInterval in Runtime logic ? Oh, NO! Sorry! It only seems to run well on IOS, on Android? What about the effect? Still not! ! ! Give it up, boy.

3. Use
Director:getInstance():getScheduler():setTimeScale(1) ? If you try it, then congratulations, I can't feel the effect by myself. 4. Okay! Or talk about my little way, by the way, there is an acceleration function. [Note: If the maximum frame rate of the device is lower than the frame rate you set, the acceleration will have no effect] setAnimationInterval(  


1.0  / 60 );//The default is the system built-in

float lkDelta = -1;

 

void XXXXX::update(float delta)

{

    if (!isFastFPS) {

        lkDelta  + = delta;

        if  ( lkDelta  <=  0.0666f  &&  lkDelta  >=  0 ) { //FPS:15 0.0666f The time required for each frame, lkDelta >= 0:[ This time is not checked at the first frame ]

            return;

        }

        if (lkDelta < 0) {

            lkDelta  =  0 ;

        } else {

            lkDelta  - =  0.0666f ;

        }

     }

    logic();

    draw();

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326641574&siteId=291194637
Recommended