2

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 */ 
Emmy
  • 3,949
  • 5
  • 28
  • 30
  • Can you give more detail about "cocos2d-x does not pick the right images for the right resolution from the right directory"? Have you traced your code in LLDB? – Shane Hou Apr 10 '13 at 04:40
  • Hi Reck: 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. – Emmy Apr 10 '13 at 06:13
  • @Emmy hi Emmy, could you please tell me how you did this because I have spent a day doing this and its still not fixed. I tried making different folders, also tried keeping same folders but images with "-hd" prefix. For different folders, it doesnt show correctly in Cocosbuilder it shows only if both non-hd and -hd images are in the same folder. Plus even after that on device its not loading hd images. – ShayanK Apr 20 '13 at 18:08
  • 1
    @ShayanAli , please see my answer below. you need to setup the resource structure in cocos2d-x static Resource smallResource = { cocos2d::CCSizeMake(480, 320), "ccb/resources-iphone/" }; static Resource mediumResource = { cocos2d::CCSizeMake(960, 640), "ccb/resources-iphonehd/" }; static Resource largeResource = { cocos2d::CCSizeMake(1024, 768), "ccb/resources-ipad/" }; static Resource xlargeResource = { cocos2d::CCSizeMake(2048, 1536), "ccb/resources-ipadhd/" }; – Emmy Apr 21 '13 at 22:49
  • @Emmy thanks for reply. So should I put ccbi file in the root of "ccb" folder and put resources being used in the ccbi file inside that folder? I tried that but it sometimes loads hd resources and sometimes it doesnt. – ShayanK Apr 22 '13 at 08:04
  • Thanks for your help, but I have actually given up, I wont be using cocos-builder it just took away so much time without solving anything :/ – ShayanK Apr 22 '13 at 08:52
  • I still having problems with cocosbuilder for cocos2dx. It took my a lot of time and it is extremely unstable. I am kind of giving it up too. :( I can get the resources working with cocosbuilder. but there are lot of other things do work. sometimes it works, sometimes it doesnt. very frustrated. – Emmy Apr 22 '13 at 09:35

4 Answers4

3

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.

Emmy
  • 3,949
  • 5
  • 28
  • 30
3

The following tutorial describes how to integrate CocosBuilder 3.0 multi-resolution resources into a cocos2d-x project: http://2sa-studio.blogspot.com/2013/04/setup-cross-platform-project-with.html. That may help you.

sdabet
  • 18,360
  • 11
  • 89
  • 158
0

I think regardless of in which "Folders" you store your images, they have to be named according to the usual pattern to conform to the cocos2d convention.

fish.png
fish-hd.png

Maybe your folder structure is from an Android project?

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • Mundi: I think for the new cocos2d-x release, they use the same image name but different folders. – Emmy Apr 08 '13 at 21:10
0

Wrong, appending -hd for fish.png is no longer supported in cocosbuilder 3.0 alpha. instead, you must place your resources using ipadhd resolution in 'resources-auto' folder. cocosbuilder will create an directory for each screen resolution, where your resources files has the appropiate resolution but with same filename.

The problem I have is that if I added these directories for ipad, iPhone-hd, iPhone-hd as targets into my iOS project, I get a COPYPNG error because I'm having to copy several files with same name.