General Android Project entry:
Src/org/cocos2dx/cpp_empty_test_diff/mainactivity.java
Cocos2d-x entrance slightly different
Src/org/cocos2dx/lib/cocos2dxactivity.java
See Onloadnativelibraries loading NDK compilation generated by. So
The application is now started.
Then use JNI to invoke C + + content and launch the game engine.
The specific is:
Cocos2dxactivity.java Init, Oncreateview
New Cocos2dxglsurfaceview(This)
Cocos2dxglsurfaceview extends Glsurfaceview event callback function similar to Win32, involving keyboard and touch, etc.
Cocos2dxactivity.java Init in This.mGLSurfaceView.setCocos2dxRenderer (new cocos2dxrenderer());
Cocos2dxrenderer Implements Glsurfaceview.renderer
See the public void Ondrawframe(final GL10 GL) function, which is the starting point of the engine's cycle
Does not care about frame rate processing, the function is simply called the Cocos2dxrenderer.nativerender();
Back to Cocos2dxactivity.java
private static native void Nativerender ();
private static native void Nativeinit (final int pWidth, final int pheight);
These functions are the knowledge of JNI and the implementation of the method in. So
respectively:
void Jnicall Java_org_cocos2dx_lib_cocos2dxrenderer_nativerender in java_org_cocos2dx_lib_cocos2dxrenderer.cpp
The java_org_cocos2dx_lib_cocos2dxrenderer_nativeinit in Javaactivity-android.cpp
void Jnicall Java_org_cocos2dx_lib_cocos2dxrenderer_nativerender (jnienv* env) { cocos2d::D irector::getinstance ()mainloop (); }
Can see the call of Mainloop;
void Java_org_cocos2dx_lib_cocos2dxrenderer_nativeinit (jnienv* env, Jobject thiz, Jint W, Jint h) { = Director->Getopenglview (); = Cocos2d::glviewimpl::create ("Android app"); Glview// frame Size first-hand information director->setopenglview (glview); Cocos2d::application::getinstance ()// The run here is empty }
The rest of the process is basically the same as the iOS process, see "cocos2d-x Simple recording on iOS";
Not familiar with Android, just log on to this
Cocos2d-x simple recording of the mating on Android