1、java端
1、Cocos2dxRenderer类
@Override
public void onDrawFrame(final GL10 gl) {
/*
* No need to use algorithm in default(60 FPS) situation,
* since onDrawFrame() was called by system 60 times per second by default.
*/
if (sAnimationInterval <= 1.0 / 60 * Cocos2dxRenderer.NANOSECONDSPERSECOND) {
Cocos2dxRenderer.nativeRender();
} else {
final long now = System.nanoTime();
final long remain = mLastTickInNanoSeconds + Cocos2dxRenderer.sAnimationInterval - now;
if (remain > 0) {
try {
Thread.sleep(remain / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
} catch (final Exception e) {
}
}
/*
* Render time MUST be counted in, or the FPS will slower than appointed.
*/
mLastTickInNanoSeconds = System.nanoTime();
Cocos2dxRenderer.nativeRender(); //调用C++部分的函数
}
}1、Cocos2dxRenderer类
@Override
pu