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.首先将手机设置为调试模式 方法:设置——应用程序——开 ...
随机推荐
- dedecms增加自定义表单管理员
打开\dede\inc\grouplist.txt 添加 >>自定义表单 >f_List>列出表单 >f_New>新建表单 >f_Edit>编辑表单 & ...
- 【JMeter4.0学习(一)】之FTP性能测试脚本开发,并实现上传下载功能
参考:<Jmeter常用脚本开发之FTP请求>感谢作者:rosa2015 一.首先,搭建FTP服务器,参考地址:<[FTP]之windows8.1上搭建FTP服务器方法> 二. ...
- horizontalDragMaxWidth:0;就没有水平滚动条了
jquery.jscrollpane.css JScrollPane工作所必须的基本的CSS样式.jquery.min.jsjQuery作为javascript库必须提前引入.jquery.mouse ...
- XSD文件详解
XSD (xml Schema Definition) Xml Schema的用途 1. 定义一个Xml文档中都有什么元素 2. 定义一个Xml文档中都会有什么属性 3. 定义某个节点的都有什么 ...
- 删除路径下的文件以及子路径。(范例“E:/www/”)
/// <summary> /// 删除路径下的文件以及子路径. /// </summary> /// <param name="dir">目标 ...
- swift中的?和!理解
本文转载至 http://www.cnblogs.com/dugulong/p/3770367.html 首先贴cocoachina上某位大大的帖子: Swift语言使用var定义变量,但和别 ...
- cmder 使用 linux bash 管道符 | grep 来筛选文件
ls -l | grep -i fira -rw-r--r-- 用户名 Feb : FiraCode-Bold.otf -rw-r--r-- 用户名 Nov FiraCode-Bold_01.ttf ...
- NSURLSession各文件关系
NSURLSession 通过session创建任务 @property (class, readonly, strong) NSURLSession *sharedSession; + (NSU ...
- CoreMotion 加速器陀螺仪
初始化CoreMotion #import <CoreMotion/CoreMotion.h> CMMotionManager *motionManager = [[CMMotionMan ...
- cocoapods最新使用
1.首先用淘宝的Ruby镜像来访问CocoaPods,打开终端输入以下命令: (1)gem sources --remove http://ruby.gems.org/ (移除现有Ruby默认源) ...