How to support multi-resolution?


Android have a lot of resolution.
(and if i support ios, i’ll meet more resolution)

I was resolve this problem when i use libgdx, i use camera’s viewport projection.

but i don’t know how to resolve this problem in cocos2d-x.

I did search many time, but i can’t find solution.

please help me.

by korean,

안드로이드에는 많은 해상도가 있습니다.
(만약에 ios도 지원한다면 더 많은 해상도를 지원해야하죠)
Libgdx 엔진을 썼을 때에는 이게 3d 게임엔진이였기 때문에 camera의 viewport projection을 이용하여 해결했었습니다.
하지만 cocos2d-x에서는 어떻게 이 문제를 해결해야 할지 모르겠습니다.
전 굉장이 많이 검색을 했지만 해결책을 찾지 못했습니다.
누가 제발 도와줘요!


You can select one middle resource (for example 800*480), and use the following code. When you run your application on different device, the resource will be scaled to fill the screen.

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv*  env, jobject thiz, jint w, jint h)
    if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView())
    cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView();
        view->setFrameWidthAndHeight(w, h);
        // if you want to run in WVGA with HVGA resource, set it
        // view->create(480, 320); 
        view->create(800, 480);  // add this code

        AppDelegate *pAppDelegate = new AppDelegate();


where insert this code??


In the helloworld project, the file path is ‘cocos2d-x\HelloWorld\android\jni\helloworld\main.cpp’.


I try to use method(using middle resource 800*480), but the game on 480x320 and 1280x720 has black bar… it can’t fill all screen.


James Chen wrote:

In the helloworld project, the file path is ‘cocos2d-xHelloWorldandroidjnihelloworldmain.cpp’.

I did insert code which “view~~>create" under "// view~~>create(480,320)”.
But still does not resize the screen.
I use desire hd2 & galaxy nexus.
On Desire HD2, it was not matter.
But on Galaxy Nexus, it is big matter……

I resolve this problem.
first, i change “view~~>create" to "view~~>create(480,800).
I wasn’t compile after modify main.cpp.