As I know cocos2d-x do like this:
Activity starts > onCreate> onStart > onResume> init CCEGLView -> init AppDelegate
so when it calls onResume ,it can be touched.
If you touch at that time , it will call jni to do :
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) {
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y);
}
but it will case crash !
because CCDirector::sharedDirector()->setOpenGLView(CCEGLView *pobOpenGLView)
is called in " init AppDelegate " after the touch ,
so CCDirector::sharedDirector()->getOpenGLView()
will return NULL!
so I think this cocos2dx\platform\android\jni\TouchesJni.cpp should be modified.
like this:
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) {
if(cocos2d::CCDirector::sharedDirector()->getOpenGLView())
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->handleTouchesBegin(1, &id, &x, &y);
}