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에서는 어떻게 이 문제를 해결해야 할지 모르겠습니다.
전 굉장이 많이 검색을 했지만 해결책을 찾지 못했습니다.
누가 제발 도와줘요!
if
{
Util::scaleY = viewSize.height / g_fBaseImageHeight;
Util::scaleY_reverse = g_fBaseImageHeight / viewSize.height;
}
if
{
Util::scaleX = viewSize.width / g_fBaseImageWidth;
Util::scaleX_reverse = g_fBaseImageWidth / viewSize.width;
}
node~~>setScaleX;
node~~>setScaleY;
Util::scaleRatio = / 2;
}
}
위 함수들을 이용해서 setDefinition 함수는 최초 어플이 실행될때 한번 해서 계산해주면 됩니다.
AppDelegate.cpp 에 bool AppDelegate::applicationDidFinishLaunching 에서 실행 해주면 되구요.
setScaleNode 함수는 Layer 마다 해주면 되요.
최상위 레이어에 한번 해주면 됩니다.
HelloWorld 라는 Layer가 있다면 HelloWorld::init 함수 안에서 Util::setScaleNode; 를 호출 해주시면 됩니다~
그리고 위와 같이 했을 경우 포지션 잡을 때 ccp 나 CCPointMake 대신 위에 정의 해준 POS () 를 이용해서 잡으시면 되요.
이유는 레이어를 확대/축소 하였을 때 중점 기준으로 확대/축소가 되기 때문에 그 차이 만큼 생긴 여백을 나중에 옮겨주기 때문이에요.