//这个类关注几个callback就好
1.onSurfaceCreated
这里调用了一个本地方法nativeInit,负责给导演设置了glview并调用了application的run方法
联想到linux的实现,看样子android的大循环也开启了,但令人感到奇怪的是,android的application
的run方法只调用了applicationDidFinishLaunching而没哟类似linux的大循环。。。问题4
吼吼,继续走起
2.onSurfaceChanged
3.onDrawFrame
@Override
onDrawFrame(finalGL10gl){
/*
*Noneedtousealgorithmindefault(60FPS)situation,
*sinceonDrawFrame()wascalledbysystem60timespersecondbydefault.
*/
(sAnimationInterval<=1.0/60*Cocos2dxRenderer.NANOSECONDSPERSECOND){
Cocos2dxRenderer.nativeRender();
}
else
{
final
long
now=System.nanoTime();
interval=now-
.mLastTickInNanoSeconds;
(interval<Cocos2dxRenderer.sAnimationInterval){
try
{
Thread.sleep((Cocos2dxRenderer.sAnimationInterval-interval)/Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
catch
(finalExceptione){
}
}
/*
*RendertimeMUSTbecountedin,ortheFPSwillslowerthanappointed.
*/
.mLastTickInNanoSeconds=System.nanoTime();
Cocos2dxRenderer.nativeRender();
}
}
4.Cocos2dxRenderer.nativeRender
JNIEXPORT
JNICALLJava_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender(JNIEnv*env){
cocos2d::Director::getInstance()->mainLoop();
}
|