zoukankan      html  css  js  c++  java
  • cocos2dx 锁定30帧设置

    修改代码:

    AppDelegate.cpp

    // set FPS. the default value is 1.0/60 if you don't call this

    pDirector->setAnimationInterval(1.0 / 30);

    还有就是:Cocos2dxRenderer.java

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

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

    ...

    @Override

    public void onDrawFrame(final GL10 gl) {

    /*

    * FPS controlling algorithm is not accurate, and it will slow down FPS

    * on some devices. So comment FPS controlling code.

    */

    final long nowInNanoSeconds = System.nanoTime();

    // should render a frame when onDrawFrame() is called or there is a

    // "ghost"

    Cocos2dxRenderer.nativeRender();

    final long afterRenderNano = System.nanoTime();

    //final long interval = afterRenderNano - mLastTickInNanoSeconds - Cocos2dxRenderer.sAnimationInterval;// afterRenderNano - nowInNanoSeconds;//nowInNanoSeconds - this.mLastTickInNanoSeconds;

    final long interval = afterRenderNano - nowInNanoSeconds;

    // fps controlling

    if (interval < Cocos2dxRenderer.sAnimationInterval) {

    //Log.d("onDrawFrame", "Cancel frame" + interval + "/" +Cocos2dxRenderer.sAnimationInterval);

    try {

    // because we render it before, so we should sleep twice time interval

    Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);

    } catch (final Exception e) {

    }

    }

    //this.mLastTickInNanoSeconds = nowInNanoSeconds;

    }

  • 相关阅读:
    VR虚拟现实眼镜那些事
    C#使用MysqlBackup.Net 备份MySQL数据库
    AgileConfig服务端搭建
    IE浏览器,各版本的请求头信息
    搜索算法
    一个完整的信号采集系统项目开发流程
    Linux内核模块简介
    搭建wordpress开发环境
    AbstractRoutingDataSource+AOP+JNDI实现spring动态数据源
    Linux 挂载磁盘记录
  • 原文地址:https://www.cnblogs.com/ADaii/p/3842427.html
Copyright © 2011-2022 走看看