android - How to make TMXTiledMap responsive? -


my game 2d car-based one, straight infinite map i've been able add random obstacles. there 3 positions car can at, , working fine.

the point i've noticed not responsive, , tried make responsive adding line these 1 appdelegate.cpp:

glview->setdesignresolutionsize(1024.0, 600.0, kresolutionfixedwidth); 

i've tried use kresolutionfixedwidth, kresolutionfixedheight , others 5 variables can put there, got black lines along screen , every single screen breakdown can imagine -.-'

i can figure out need resize tmxtiledmap manually because of nature of tiles (i did tiled), don't know how face problem.

note i'm developing 1024x600 android device want support @ least common resolutions both tablets , smartphones.

there 2 resolution policies want use.

if use no border shouldn't see black bars, engine crop design resolution won't want put ui in corners, or you'll want use visible origin , visible size calculate positions.

if use exact fit should set design resolution devices exact size, , you're responsible positioning , scaling correctly avoid distortion.

you need scale art depending on policy , design resolution choices if seeing black bars.

have read through wiki page? http://www.cocos2d-x.org/wiki/multi_resolution_support

here's 1 of our games:

auto director = director::getinstance(); auto glview = director->getopenglview();  float contentscalefactor = 1.f;  // set design resolution size framesize = glview->getframesize(); size designsize = glview->getdesignresolutionsize(); cclog("defaults:"); cclog("framesize = {%f,%f}", framesize.width, framesize.height); cclog("visiblesize = {%f,%f}", glview->getvisiblesize().width, glview->getvisiblesize().height); cclog("designsize = {%f,%f}", designsize.width, designsize.height); cclog("contentscalefactor = %f", director->getcontentscalefactor());  vec2 origin = director->getvisibleorigin(); cclog("visiblesize = %s", cstrfromsize(director->getvisiblesize())); cclog("origin = {%f,%f}", origin.x, origin.y);  // retina?  contentscalefactor = director->getcontentscalefactor(); float designwidth = framesize.width / contentscalefactor; float designheight = framesize.height / contentscalefactor; cclog("contentscale = %f, designwidth/height = {%f,%f}", contentscalefactor, designwidth, designheight);  glview->setdesignresolutionsize(designwidth, designheight, resolutionpolicy::exact_fit);  // designed game 480x320 (hence divisors) // used scale full screen backgrounds float fullwidthscalefactor = designwidth/480.f; // used scale ui float largescalefactor = floorf(designheight/320.f); // round closest half step (1.0,1.5,2.0,2.5,3.0,etc) // used scaling ui pixel art affected .1 scales float largescalefactorexact = floorf(designheight * 2.f / 320.f) * 0.5f; // used scale ui must touchable (larger on high desnsity) float largescalefactorui = stround(designheight / 320.f);  // forces minimum of 1x scale (we should not support these devices) float scalefitall = designwidth > designheight ? designheight/320.f : designwidth/480.f; if(largescalefactor < 1.f)     largescalefactor = scalefitall; if(largescalefactorexact < 1.f)     largescalefactorexact = scalefitall; if(largescalefactorui < 1.f)     largescalefactorui = scalefitall; 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -