Cocos2d-X学习——Android不同设备FPS不同问题
2024-10-20 21:02:34
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
最新文章
- PHP中include和require的区别详解
- Delphi的文件操作
- xshell下载文件到本地/上传文件到服务器
- ViewController与outlet绑定
- 用nginx做反向代理来访问防外链图片
- 关于flume中的几个疑惑
- ZOJ 1001 A + B Problem
- Android or iOS 运行 meteor App 屏幕一片空白 White screen的解决方法
- [原创]jQuery的this和$(this)
- C++输入输出流的重载
- SQL FOR XML PATH 用法
- 201521123073 《Java程序设计》第7周学习总结
- C 真正理解二级指针
- str_replace替换换行符失败原因
- 关于js中原生构造函数的继承
- 什么是 Spring Boot
- Android使用AIDL跨进程通信
- Windows安装pip方法
- HDU.5628.Clarke and math(狄利克雷卷积 快速幂)
- 一起SQL引发OOM的解决思路与过程(转载)
热门文章
- SQL2000下修复某数据库的经历
- Linux新手笔记 源 安装chromium
- 指定字符串加密(对称加密DES)
- 利用console控制台调试php代码
- verilog中读取文件中的字符串_modelsim高级仿真
- document.createElement在IE和Firefox下的差异
- Trie三兄弟——标准Trie、压缩Trie、后缀Trie
- perl5 第十三章 Perl的面向对象编程
- [转载]cin、cin.get()、cin.getline()、getline()、gets()函数的用法
- 3027 - Corporative Network(并差集)