Domanda

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 */ 
È stato utile?

Soluzione

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.

Altri suggerimenti

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.

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?

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top