androidipadretina-displaycocos2d-xcocosbuilder

Cocos2d-x and CocosBuilder multi-resolution for ios and android


I followed the instruction in the link below and I can get multi-resolution work on ios platform without cocosBuilder. http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

When I use cocosbuilder ccbi file, the images displayed on the ipad screen are still iphone image.

cocosbuilder published the resource directory like this cocosbuilder published directory

but it seems like cocos2d-x does not pick the right images for the right resolution from the right directory.

Here is my resource setting in the code. I am testing it on ipad 3 with HD.

#define DESIGN_RESOLUTION_480X320 0
#define DESIGN_RESOLUTION_1024X768 1
#define DESIGN_RESOLUTION_2048X1536 2

/* If you want to switch design resolution, change next line */
#define TARGET_DESIGN_RESOLUTION_SIZE DESIGN_RESOLUTION_2048X1536

typedef struct tagResource {
cocos2d::CCSize size;
char directory100;
}Resource;

static Resource smallResource = { cocos2d::CCSizeMake(480, 320), "ccb/resources-iphone" };
static Resource mediumResource = { cocos2d::CCSizeMake(1024, 768), "ccb/resources-ipad" };
static Resource largeResource = { cocos2d::CCSizeMake(2048, 1536), "ccb/resources-ipadhd" };

#if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(480, 320);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1024X768)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(1024, 768);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_2048X1536)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(2048, 1536);
#else
#error unknown target design resolution!
#endif

// The font size 24 is designed for small resolution, so we should change it to fit for current design resolution
#define TITLE_FONT_SIZE (cocos2d::CCEGLView::sharedOpenGLView()->getDesignResolutionSize().width / smallResource.size.width * 24)

#endif /* APPMACROS_H */ 

Solution

  • I am using the latest release cocos2d-x 2.1.2 and cocosbuilder 3.0. After a half day straggle with the issue, I found the solution.

    The reason is that when cocosbuilder published the resource, it created a very nice directories structure to put different resolution images to the different folder. I assumed cocos2d-x will pick the right directory work with cocosbuilder published file structure. I was wrong. I had to manually set the resource directory in cocos2d-x to match the cocosbuilder published directory. After I did that, everything works fine.