cocos2dx 屏幕大小

前端之家收集整理的这篇文章主要介绍了cocos2dx 屏幕大小前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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(); 
    }
}
原文链接:https://www.f2er.com/cocos2dx/343820.html

猜你在找的Cocos2d-x相关文章