2

I'm working on a game which should have a constant height(480.0) and because so I wrote that code below.. what's wrong with it is that I have sprite sheets power of 2s for sd here're normal images, for hd - double size and for iPad retina - 4 times bigger; so in this case when I draw my sprites from scene images are not correctly drawn.. And I guess that's because CCSpriteFrame is using CC_ContentScaleFactor() to calculate frame of a image and it cut's wrong frame..

does anybody has any idea how to solve it? :?

CCSize designResolutionSize = CCSize(320,480);
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

pDirector->setOpenGLView(pEGLView);

pEGLView->setDesignResolutionSize(designResolutionSize.width,
                                  designResolutionSize.height,
                                  kResolutionFixedHeight);

CCSize size = CCEGLView::sharedOpenGLView()->getFrameSize();

std::vector<std::string> res;
if(size.width >= 2048 || size.height >= 2048){
    res.push_back("ipadhd");
}
else if(size.width >= 960 || size.height >= 960){
    res.push_back("hd");
}
else {
    res.push_back("sd");
}

CCFileUtils::sharedFileUtils()->setSearchPaths(res);
CCDirector::sharedDirector()->setContentScaleFactor(size.height / designResolutionSize.height);

Thanks, George..

kjhkjhkjh
  • 412
  • 3
  • 12
  • just to make sure, you have gone through: http://cocos2d-x.org/wiki/Multi_resolution_support – GameDeveloper May 13 '14 at 18:58
  • It's a bug... so I did it with another solution, – kjhkjhkjh May 14 '14 at 08:29
  • Hello 0Silencer, how you solve your problem? I have the same problem with cocos2d-x 2.2.3 and levelhelper 1.4.989 – mistic May 15 '14 at 16:38
  • I've solved the problem re-writing the code of LevelHelper Loader. I gave support for the multi resolution system of cocos2d-x and all work. – mistic May 16 '14 at 02:32
  • kResolutionFixedHeight has some bad outcomes so I had to use kResolutionNoBorder, and also SpriteBatchNodes not working while you have changed the content scale factor.. – kjhkjhkjh May 17 '14 at 10:58

0 Answers0