我使用cocos2d 1.1,xCode 4.5作爲我的遊戲程序。我想重新編碼我的遊戲以支持iPhone 5.但是我遇到了問題:cocos2d 1.1無法檢測到視網膜4英寸的精靈。cocos2d 1.1 sprite for retina 4英寸iPhone5
[email protected] - 工作正常,但遊戲的精靈顯示爲* -hd.png。 看來cocos2d 1.1只能檢測到* -hd.png,但是我添加了sprite * [email protected]。
對不起,我的英文。
這個問題的解決是在CCFileUtils.m文件下面寫塞爾吉奧。
我的確在方法變化不大+(的NSString *)getDoubleResolutionImage:(的NSString *)路徑
+(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;
}
,並添加文件ccConfig.h
#ifndef CC_RETINA4_DISPLAY_FILENAME_SUFFIX
#define CC_RETINA4_DISPLAY_FILENAME_SUFFIX @"[email protected]"
#endif
如果有人有通知,請寫
遊戲必須支持3,5和4英寸的視網膜 –
@AlexanderSharunov,最好的選擇是更新你的cocos2D lib到2.0或者只是從2.0的圖像加載部分,並使用iPad 3的ipadhd。 – Guru
是否該項目可以自動更新?因爲我不知道它是如何做到的。是否支持cocos2D 2.0 * [email protected]? –