I use cocos2d 1.1, xCode 4.5 for my game's progect. I would like to recode my game for support the iPhone 5. But I faced with problem: cocos2d 1.1 can't detected sprite for retina 4 inch.
Default-568h@2x.png - work fine, but the game's sprites appears as *-hd.png. It seems cocos2d 1.1 can detected just *-hd.png, however I added the sprites *-568h@2x.png.
Sorry for my English.
The solving of this problem is in CCFileUtils.m file as written below sergio.
I did the little changes in method +(NSString*) getDoubleResolutionImage:(NSString*)path
+(NSString*) getDoubleResolutionImage:(NSString*)path
{
#if CC_IS_RETINA_DISPLAY_SUPPORTED
if( CC_CONTENT_SCALE_FACTOR() == 2 )
{
NSString *pathWithoutExtension = [path stringByDeletingPathExtension];
NSString *name = [pathWithoutExtension lastPathComponent];
NSString *extension = [path pathExtension];
if( [extension isEqualToString:@"ccz"] || [extension isEqualToString:@"gz"] )
{
extension = [NSString stringWithFormat:@"%@.%@", [pathWithoutExtension pathExtension], extension];
pathWithoutExtension = [pathWithoutExtension stringByDeletingPathExtension];
}
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f)
{
if( [name rangeOfString:CC_RETINA4_DISPLAY_FILENAME_SUFFIX].location != NSNotFound ) {
CCLOG(@"cocos2d: WARNING Filename(%@) already has the suffix %@. Using it.", name, CC_RETINA4_DISPLAY_FILENAME_SUFFIX);
return path;
}
NSString *retinaName = [pathWithoutExtension stringByAppendingString:CC_RETINA4_DISPLAY_FILENAME_SUFFIX];
retinaName = [retinaName stringByAppendingPathExtension:extension];
if( [__localFileManager fileExistsAtPath:retinaName] )
{
return retinaName;
}
}
if( [name rangeOfString:CC_RETINA_DISPLAY_FILENAME_SUFFIX].location != NSNotFound ) {
CCLOG(@"cocos2d: WARNING Filename(%@) already has the suffix %@. Using it.", name, CC_RETINA_DISPLAY_FILENAME_SUFFIX);
return path;
}
NSString *retinaName = [pathWithoutExtension stringByAppendingString:CC_RETINA_DISPLAY_FILENAME_SUFFIX];
retinaName = [retinaName stringByAppendingPathExtension:extension];
if( [__localFileManager fileExistsAtPath:retinaName] )
{
return retinaName;
}
CCLOG(@"cocos2d: CCFileUtils: Warning HD file not found: %@", [retinaName lastPathComponent] );
}
#endif // CC_IS_RETINA_DISPLAY_SUPPORTED
return path;
}
and also add in file ccConfig.h
#ifndef CC_RETINA4_DISPLAY_FILENAME_SUFFIX
#define CC_RETINA4_DISPLAY_FILENAME_SUFFIX @"-568h@2x"
#endif
If someone have a notice, please write