cocos2d-x在android真机上设置帧率无效的问题
通过setAnimationInterval设置帧频时,发现在android下没有效果的
在Cocos2dxRenderer .java文件里面找到了onDrawFrame这个函数。里面有句注释 :
FPS controlling algorithm is not accurate, and it will slow down FPS on some devices. So comment FPS controlling code.
这个函数里的大部分代码都被注释掉了
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();
/*
// 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;
*/
}
经过google后暂时找到了解决方案,是否有问题需要待测试:
private long renderingElapsedTime; @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.
*/ try {
if (renderingElapsedTime< Cocos2dxRenderer.sAnimationInterval) {
Thread.sleep((Cocos2dxRenderer.sAnimationInterval - renderingElapsedTime) / NANOSECONDSPERMICROSECOND);
}
} catch (InterruptedException e) {
e.printStackTrace();
} // Get the timestamp when rendering started
long renderingStartedTimestamp = System.nanoTime(); // should render a frame when onDrawFrame() is called or there is a
// "ghost"
Cocos2dxRenderer.nativeRender(); // Calculate the elapsed time during rendering
renderingElapsedTime = (System.nanoTime() - renderingStartedTimestamp);
}
cocos2d-x在android真机上设置帧率无效的问题的更多相关文章
- React-Native项目在Android真机上调试
目录 1.确保你的设备已经成功连接.可以终端输入adb devices来查看: 2.终端运行npm start 开启本地服务,成功后运行react-native run-android来在设备上安装并 ...
- 在android真机上使用sqlite3
#zijun#2013.10.29#QQ:223663737 在android真机上使用sqlite3 前期准备: 1:保证手机已经ROOT 操作步骤: 1 : 打开CMD 2 : 进入android ...
- [转]Fiddler抓取Android真机上的HTTPS包
此篇文章转载自:http://blog.csdn.net/roland_sun/article/details/30078353 工作中经常会需要对一些app进行抓包, 但是每次默认都是只抓http请 ...
- cocos2dx - 部署到android真机上错误整理
利用Cgywin编译工具来将cocos2dx 在Android运行所需要的C++文件编译 1. ./build_native.sh(最后一把执行出错) please define NDK_ROOT i ...
- 导出android真机上应用的apk文件
1. 首先你的手机要开启调试模式 2. 终端输入命令行 (这个时候需要在手机端打开此应用.它的思路是抓取出当前窗口的包名.以下命令操作自己未亲自验证.) adb shell dumpsys windo ...
- Android的TextView设置padding无效
I finally found the problem I have to set the background first before setting the padding. Setting t ...
- cocos2d-x 不能在android真机debug的问题
最近在做cocos2d-x开发的时候,发现在android真机上不能调试C++代码,显示如下警告信息 Ignoring packet error, continuing... warning: unr ...
- 通过adb shell操作android真机的SQLite数据库
要通过命令行直接操作android真机上的SQLite数据库,可以直接通过adb shell来完成,不过,前提是必须获得root权限. 另外,android系统其实就是linux的shell,这个应该 ...
- 如何在真机上调试Android应用程序(图文详解)(zz)
http://www.cnblogs.com/lanxuezaipiao/archive/2013/03/11/2953564.html 1.首先将手机设置为调试模式 方法:设置——应用程序——开 ...
随机推荐
- foxmail 客户端 LOGIN Login error password error
显示这个错误是我在更换电脑时,将E:\Foxmail 7.2\Storage\15167136106@163.com 账户 移动到新的电脑上,并在新电脑上创建用户,总是报:账户或密码错误 我输入的密码 ...
- MySQL_知识点
1.执行顺序 语句模板: (8)SELECT (9)DISTINCT (11)<Top Num> <select list> (1)FROM [left_table] (3)& ...
- oracle索引的理解
1.当查询表时where条件中有多个索引时,优先使用主键索引,其它索引会失效. 2.当查询的返回的数据占总量数据的百分比小于20%时,建索引才有效果 3.不是主键的索引值可以为空,主键索引不能为空. ...
- Oracle集群和灾备解决方案介绍
Oracle本身有各种各样的解决方案,本文主要是对以下几种解决方案做一下简单的梳理. 1. Oracle Rac解决方案. Oracle Rac主要通过两台Oracle服务器来组件集群,提高Or ...
- 【Axure插件】之浏览器打开失败
下载地址:https://files.cnblogs.com/files/Owen-ET/AxureRP_for_chorme_0_6_2.xml 下载后的文件后缀修改为:AxureRP_for_ch ...
- PHP浮点数运算精度造成的,订单金额支付经常少1分的问题
最近碰见一个奇怪的问题,商城通过微信支付的订单经常少一分钱,经过排查是PHP浮点运算精度问题造成的 由PHP浮点数运算精度造成的,鸟哥的Bolg有详细的说明.http://www.laruence.c ...
- JavaWeb学习总结第六篇--认识Session机制
认识Session机制 前文也提到过,常用的会话跟踪有两种技术:Cookie和Session.今天就为大家讲解一下Session机制. 什么是Session? Session是另一种记录客户状态的机制 ...
- jqury 如何获取 kindeditor 中textarea 的值
获取文本内容,可是的创建时怎么也不能获取,利用FF的firebug查看到自己所写的内容在一个iframe中,于是想从iframe中获取文本,想要用 $(“ifame”).html();获取内容,可是依 ...
- Cross Frame Script (跨框架脚本) 攻击
一.Cross Frame Script (跨框架脚本) 攻击 什么是Cross Frame Script? 很简单,做个实验就知道了.把下面的这段HTML代码另存为一个html文件,然后用ie浏览器 ...
- SELinux状态修改
查看SELinux状态: 1./usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态 SELinux status: ...