1、java端
//mScreenWidth mScreenHeight 屏幕的宽和高 @Override public void onSurfaceCreated(final GL10 pGL10,final EGLConfig pEGLConfig) { Cocos2dxRenderer.nativeInit(this.mScreenWidth,this.mScreenHeight); this.mLastTickInNanoSeconds = System.nanoTime(); }
2、C++端(proj.android/jni/main.cpp):
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env,jobject thiz,jint w,jint h) { if (!CCDirector::sharedDirector()->getOpenGLView()) { CCEGLView *view = CCEGLView::sharedOpenGLView(); view->setFrameSize(w,h); //设置屏幕大小 AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication()->run(); } else { ccGLInvalidateStateCache(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); ccDrawInit(); CCTextureCache::reloadAllTextures(); CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND,NULL); CCDirector::sharedDirector()->setGLDefaultValues(); } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。