2014-07-16

环境:Cocos2dx 2.2.4

AppDelegate.cpp中FPS设置为 60

pDirector->setAnimationInterval(1.0 / 60);



问题:在两台Android机器上跑。 两台的FPS不一样

I9100: 4.0系统,FPS 约60,(改动FPS为30,也会改变)

S5700: 2.3系统,FPS 约80,(改动FPS为30,照样80)

这样就导致了在游戏刷帧的时候,两台机器跑的速度不一样了。



解决方法例如以下(应该仅仅有Android有这个问题)

改动Android中cocos2dx的 Cocos2dxRenderer.java代码

(PS:假设依照官方的凝视改动,也不能达到FPS一致)

	@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();
// final long interval = nowInNanoSeconds - this.mLastTickInNanoSeconds;
// */ // should render a frame when onDrawFrame() is called or there is a
// "ghost"
Cocos2dxRenderer.nativeRender(); final long afterInNanoSeconds = System.nanoTime();
final long interval = afterInNanoSeconds - nowInNanoSeconds; // /*
// fps controlling
if (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;
// */
}

以上,谢谢

本文地址:http://blog.csdn.net/you_and_me12/article/details/37885461

最新文章

  1. PHP中include和require的区别详解
  2. Delphi的文件操作
  3. xshell下载文件到本地/上传文件到服务器
  4. ViewController与outlet绑定
  5. 用nginx做反向代理来访问防外链图片
  6. 关于flume中的几个疑惑
  7. ZOJ 1001 A + B Problem
  8. Android or iOS 运行 meteor App 屏幕一片空白 White screen的解决方法
  9. [原创]jQuery的this和$(this)
  10. C++输入输出流的重载
  11. SQL FOR XML PATH 用法
  12. 201521123073 《Java程序设计》第7周学习总结
  13. C 真正理解二级指针
  14. str_replace替换换行符失败原因
  15. 关于js中原生构造函数的继承
  16. 什么是 Spring Boot
  17. Android使用AIDL跨进程通信
  18. Windows安装pip方法
  19. HDU.5628.Clarke and math(狄利克雷卷积 快速幂)
  20. 一起SQL引发OOM的解决思路与过程(转载)

热门文章

  1. SQL2000下修复某数据库的经历
  2. Linux新手笔记 源 安装chromium
  3. 指定字符串加密(对称加密DES)
  4. 利用console控制台调试php代码
  5. verilog中读取文件中的字符串_modelsim高级仿真
  6. document.createElement在IE和Firefox下的差异
  7. Trie三兄弟——标准Trie、压缩Trie、后缀Trie
  8. perl5 第十三章 Perl的面向对象编程
  9. [转载]cin、cin.get()、cin.getline()、getline()、gets()函数的用法
  10. 3027 - Corporative Network(并差集)