2012-09-12 29 views
7

我剛剛看到announcment of iPhone 5,它說像素分辨率已更改爲1136 * 640,這樣就影響了應用程序的ASPECT RATIO。Cocos2d和新的iPhone 5長寬比

我應該如何在我的Cocos2d遊戲中處理這個問題?我爲「老」960 * 640視網膜顯示屏幕完成了所有圖形,我猜那些會在iPhone 5屏幕上變形。

對嗎?或者是否會顯示「舊分辨率」圖像而不修改高寬比並將屏幕留下黑色?

編輯:是否有一種方式來獲得的Cocos2D來檢測,如果它是iPhone 5,並在這種情況下繪製的畫面(最高960像素)的頂部的背景文件,並得到一些其他的自定義背景文件在剩下的像素中繪製(例如,這些可能是一些自定義廣告橫幅或僅適用於iPhone 5的遊戲中可用的一些額外按鈕)。

回答

9

今天早上我剛剛給我的應用程序添加了4英寸的支持。 Cocos2d在沒有修改的情況下運行良好(在模擬器中)。我所有的場景都調整了正​​確的尺寸,我只需要對某些位置進行一些修改,因爲它們是固定的座標而不是相對的。

目前沒有辦法輕鬆加載不同的圖像,我懷疑在接下來的幾天會有一個類似於-hd的新命名約定。

至於你的編輯問題,你可能會發現,一旦你啓用了4英寸模式,你的佈局將在頂部有一個很大的黑色空間。當然,你可以在那裏放任何你想要的東西。

您可以檢測它是否使用

[[UIScreen mainScreen] bounds].size.height 
+2

是否有可能接受這兩個答案? :) – mm24

6

的iOS會自動將黑色細條上的應用程序 兩側所以它仍然與應用程序最初 專爲iPhone

一些消息來源報告這個早期版本中的方式是一致的,這是from here。我們甚至不知道是否需要或需要進行哪種類型的修改才能支持iPhone 5.不用擔心。不要假設。等着瞧。

與所有其他設備一樣,將會有方法檢測確切的設備類型。再次,這將不得不等待,直到我們得到至少iOS 6。您可以加入測試計劃,希望找到,但只要它的測試版信息是在NDA下,並且您只能通過私人Apple開發者論壇。

+0

感謝。你認爲可以讓iOS 6在「黑色欄」區域繪製一些自定義的Cocos2d圖層嗎?我想將我的控件移到iOS 6設備上。 – mm24

+1

是的,那將是可能的。 –

+1

說實話我會認爲這是一個完美的地方做一些「廣告」 – renevdkooi

3

的Cocos2D一個高大的屏幕 - V2.X

與以下代碼取代CCFileUtils.h和.M並添加內委託行:[sharedFileUtils setiPhone5DisplaySuffix:@"-568h"]; // >>>>>> iPhone 5 -568h

.h

/* 
* cocos2d for iPhone: http://www.cocos2d-iphone.org 
* 
* Copyright (c) 2008-2010 Ricardo Quesada 
* Copyright (c) 2011 Zynga Inc. 
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal 
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is 
* furnished to do so, subject to the following conditions: 
* 
* The above copyright notice and this permission notice shall be included in 
* all copies or substantial portions of the Software. 
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
* THE SOFTWARE. 
* 
*/ 


#import <Foundation/Foundation.h> 
#import "../ccTypes.h" 

/** Helper class to handle file operations */ 
@interface CCFileUtils : NSObject 
{ 
    NSFileManager *fileManager_; 
    NSBundle  *bundle_; 
    NSMutableDictionary *fullPathCache_; 
    NSMutableDictionary *removeSuffixCache_; 


#ifdef __CC_PLATFORM_IOS 
    BOOL enableFallbackSuffixes_; 

    NSString *iPhoneRetinaDisplaySuffix_; 
    NSString *iPhone5DisplaySuffix_;       // <<<<<<<<<<<<< ADDED 
    NSString *iPadSuffix_; 
    NSString *iPadRetinaDisplaySuffix_; 
#endif // __CC_PLATFORM_IOS 
} 

/** NSBundle used by CCFileUtils. By default it uses [NSBundle mainBundle]. 
@since v2.0 
*/ 
@property (nonatomic, readwrite, retain) NSBundle *bundle; 

/** NSFileManager used by CCFileUtils. By default it uses its own intance. 
@since v2.0 
*/ 
@property (nonatomic, readwrite, retain) NSFileManager *fileManager; 

#ifdef __CC_PLATFORM_IOS 
/** The iPhone RetinaDisplay suffixes to load resources. 
By default it is "-hd" and "" in that order. 
Only valid on iOS. Not valid for OS X. 

@since v1.1 
*/ 
@property (nonatomic,readwrite, copy, setter = setiPhoneRetinaDisplaySuffix:) NSString *iPhoneRetinaDisplaySuffix; 





/** The iPhone 5 suffixes to load resources. 
By default it is "-hd" and "" in that order. 
Only valid on iOS. Not valid for OS X. 

@since v1.1 
*/ 
@property (nonatomic,readwrite, copy, setter = setiPhone5DisplaySuffix:) NSString *iPhone5DisplaySuffix; 





/** The iPad suffixes to load resources. 
By default it is "-ipad", "-hd", "", in that order. 
Only valid on iOS. Not valid for OS X. 

@since v1.1 
*/ 
@property (nonatomic,readwrite, copy, setter = setiPadSuffix:) NSString *iPadSuffix; 


/** Sets the iPad Retina Display suffixes to load resources. 
By default it is "-ipadhd", "-ipad", "-hd", "", in that order. 
Only valid on iOS. Not valid for OS X. 

@since v2.0 
*/ 
@property (nonatomic,readwrite, copy, setter = setiPadRetinaDisplaySuffix:) NSString *iPadRetinaDisplaySuffix; 

/** Whether of not the fallback sufixes is enabled. 
When enabled it will try to search for the following suffixes in the following order until one is found: 
    * On iPad HD : iPad HD suffix, iPad suffix, iPhone HD suffix, Without suffix 
    * On iPad  : iPad suffix, iPhone HD suffix, Without suffix 
    * On iPhone HD: iPhone HD suffix, Without suffix 

By default this functionality is off; 
*/ 
@property (nonatomic, readwrite) BOOL enableFallbackSuffixes; 

#endif // __CC_PLATFORM_IOS 

/** returns the shared file utils instance */ 
+(CCFileUtils*) sharedFileUtils; 


/** Purge cached entries. 
Will be called automatically by the Director when a memory warning is received 
*/ 
-(void) purgeCachedEntries; 

/** Returns the fullpath of an filename. 

If in iPhoneRetinaDisplay mode, and a RetinaDisplay file is found, it will return that path. 
If in iPad mode, and an iPad file is found, it will return that path. 

Examples: 

    * In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists) 
    * In iPhone RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists) 
    * In iPad RetinaDisplay mode: "image.png" -> "/full/path/image-ipadhd.png" (in case the -ipadhd file exists) 

*/ 
-(NSString*) fullPathFromRelativePath:(NSString*) relPath; 


/** Returns the fullpath of an filename including the resolution of the image. 

If in RetinaDisplay mode, and a RetinaDisplay file is found, it will return that path. 
If in iPad mode, and an iPad file is found, it will return that path. 

Examples: 

* In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists) 
* In iPhone RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists) 
* In iPad RetinaDisplay mode: "image.png" -> "/full/path/image-ipadhd.png" (in case the -ipadhd file exists) 

If an iPad file is found, it will set resolution type to kCCResolutioniPad 
If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay 

*/ 
-(NSString*) fullPathFromRelativePath:(NSString*)relPath resolutionType:(ccResolutionType*)resolutionType; 

#ifdef __CC_PLATFORM_IOS 

/** removes the suffix from a path 
* On iPhone RetinaDisplay it will remove the -hd suffix 
* On iPad it will remove the -ipad suffix 
* On iPad RetinaDisplay it will remove the -ipadhd suffix 

Only valid on iOS. Not valid for OS X. 

@since v0.99.5 
*/ 
-(NSString *)removeSuffixFromFile:(NSString*) path; 

/** Returns whether or not a given path exists with the iPhone RetinaDisplay suffix. 
Only available on iOS. Not supported on OS X. 
@since v1.1 
*/ 
-(BOOL) iPhoneRetinaDisplayFileExistsAtPath:(NSString*)filename; 






/** Returns whether or not a given path exists with the iPhone 5 suffix. 
Only available on iOS. Not supported on OS X. 
@since v1.1 
*/ 
-(BOOL) iPhone5DisplayFileExistsAtPath:(NSString*)filename; 



/** Returns whether or not a given filename exists with the iPad suffix. 
Only available on iOS. Not supported on OS X. 
@since v1.1 
*/ 
-(BOOL) iPadFileExistsAtPath:(NSString*)filename; 

/** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix. 
Only available on iOS. Not supported on OS X. 
@since v2.0 
*/ 
-(BOOL) iPadRetinaDisplayFileExistsAtPath:(NSString*)filename; 

#endif // __CC_PLATFORM_IOS 

@end 


#ifdef __cplusplus 
extern "C" { 
#endif 

/** loads a file into memory. 
the caller should release the allocated buffer. 

@returns the size of the allocated buffer 
@since v0.99.5 
*/ 
NSInteger ccLoadFileIntoMemory(const char *filename, unsigned char **out); 

#ifdef __cplusplus 
} 
#endif 

。米

/* 
* cocos2d for iPhone: http://www.cocos2d-iphone.org 
* 
* Copyright (c) 2008-2010 Ricardo Quesada 
* Copyright (c) 2011 Zynga Inc. 
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal 
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is 
* furnished to do so, subject to the following conditions: 
* 
* The above copyright notice and this permission notice shall be included in 
* all copies or substantial portions of the Software. 
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
* THE SOFTWARE. 
* 
*/ 


#import "CCFileUtils.h" 
#import "../CCConfiguration.h" 
#import "../ccMacros.h" 
#import "../ccConfig.h" 
#import "../ccTypes.h" 

enum { 
    kCCiPhone, 
    kCCiPhoneRetinaDisplay, 
    kCCiPhone5Display, 
    kCCiPad, 
    kCCiPadRetinaDisplay, 
}; 

#pragma mark - Helper free functions 

NSInteger ccLoadFileIntoMemory(const char *filename, unsigned char **out) 
{ 
    NSCAssert(out, @"ccLoadFileIntoMemory: invalid 'out' parameter"); 
    NSCAssert(&*out, @"ccLoadFileIntoMemory: invalid 'out' parameter"); 

    size_t size = 0; 
    FILE *f = fopen(filename, "rb"); 
    if(!f) { 
     *out = NULL; 
     return -1; 
    } 

    fseek(f, 0, SEEK_END); 
    size = ftell(f); 
    fseek(f, 0, SEEK_SET); 

    *out = malloc(size); 
    size_t read = fread(*out, 1, size, f); 
    if(read != size) { 
     free(*out); 
     *out = NULL; 
     return -1; 
    } 

    fclose(f); 

    return size; 
} 

#pragma mark - CCCacheValue 

@interface CCCacheValue : NSObject 
{ 
    NSString   *fullpath_; 
    ccResolutionType resolutionType_; 
} 
@property (nonatomic, readwrite, retain) NSString *fullpath; 
@property (nonatomic, readwrite) ccResolutionType resolutionType; 
@end 

@implementation CCCacheValue 
@synthesize fullpath = fullpath_, resolutionType = resolutionType_; 
-(id) initWithFullPath:(NSString*)path resolutionType:(ccResolutionType)resolutionType 
{ 
    if((self=[super init])) 
    { 
     self.fullpath = path; 
     self.resolutionType = resolutionType; 
    } 

    return self; 
} 

- (void)dealloc 
{ 
    [fullpath_ release]; 

    [super dealloc]; 
} 
@end 

#pragma mark - CCFileUtils 

#ifdef __CC_PLATFORM_IOS 
@interface CCFileUtils() 
-(NSString *) removeSuffix:(NSString*)suffix fromPath:(NSString*)path; 
-(BOOL) fileExistsAtPath:(NSString*)string withSuffix:(NSString*)suffix; 
-(NSInteger) runningDevice; 
@end 
#endif // __CC_PLATFORM_IOS 

@implementation CCFileUtils 

@synthesize fileManager=fileManager_, bundle=bundle_; 
#ifdef __CC_PLATFORM_IOS 
@synthesize iPhoneRetinaDisplaySuffix = iPhoneRetinaDisplaySuffix_; 
@synthesize iPhone5DisplaySuffix = iPhone5DisplaySuffix_; 
@synthesize iPadSuffix = iPadSuffix_; 
@synthesize iPadRetinaDisplaySuffix = iPadRetinaDisplaySuffix_; 
@synthesize enableFallbackSuffixes = enableFallbackSuffixes_; 
#endif // __CC_PLATFORM_IOS 

+ (id)sharedFileUtils 
{ 
    static dispatch_once_t pred; 
    static CCFileUtils *fileUtils = nil; 
    dispatch_once(&pred, ^{ 
     fileUtils = [[self alloc] init]; 
    }); 
    return fileUtils; 
} 

-(id) init 
{ 
    if((self=[super init])) { 
     fileManager_ = [[NSFileManager alloc] init]; 

     fullPathCache_ = [[NSMutableDictionary alloc] initWithCapacity:30]; 
     removeSuffixCache_ = [[NSMutableDictionary alloc] initWithCapacity:30]; 

     bundle_ = [[NSBundle mainBundle] retain]; 

#ifdef __CC_PLATFORM_IOS 
     iPhoneRetinaDisplaySuffix_ = @"-hd"; 
     iPhone5DisplaySuffix_ = @"-568h"; 
     iPadSuffix_ = @"-ipad"; 
     iPadRetinaDisplaySuffix_ = @"-ipadhd"; 

     enableFallbackSuffixes_ = NO; 
#endif // __CC_PLATFORM_IOS 

    } 

    return self; 
} 

-(void) purgeCachedEntries 
{ 
    [fullPathCache_ removeAllObjects]; 
    [removeSuffixCache_ removeAllObjects]; 
} 

- (void)dealloc 
{ 
    [fileManager_ release]; 
    [bundle_ release]; 
    [fullPathCache_ release]; 
    [removeSuffixCache_ release]; 

#ifdef __CC_PLATFORM_IOS  
    [iPhoneRetinaDisplaySuffix_ release]; 
    [iPhone5DisplaySuffix_ release]; 
    [iPadSuffix_ release]; 
    [iPadRetinaDisplaySuffix_ release]; 
#endif // __CC_PLATFORM_IOS 

    [super dealloc]; 
} 

-(NSString*) pathForResource:(NSString*)resource ofType:(NSString *)ext inDirectory:(NSString *)subpath 
{ 
    return [bundle_ pathForResource:resource 
          ofType:ext 
         inDirectory:subpath]; 
} 

-(NSString*) getPath:(NSString*)path forSuffix:(NSString*)suffix 
{ 
    NSString *newName = path; 

    // only recreate filename if suffix is valid 
    if(suffix && [suffix length] > 0) 
    { 
     NSString *pathWithoutExtension = [path stringByDeletingPathExtension]; 
     NSString *name = [pathWithoutExtension lastPathComponent]; 

     // check if path already has the suffix. 
     if([name rangeOfString:suffix].location == NSNotFound) { 


      NSString *extension = [path pathExtension]; 

      if([extension isEqualToString:@"ccz"] || [extension isEqualToString:@"gz"]) 
      { 
       // All ccz/gz files should be in the format filename.xxx.ccz 
       // so we need to pull off the .xxx part of the extension as well 
       extension = [NSString stringWithFormat:@"%@.%@", [pathWithoutExtension pathExtension], extension]; 
       pathWithoutExtension = [pathWithoutExtension stringByDeletingPathExtension]; 
      } 


      newName = [pathWithoutExtension stringByAppendingString:suffix]; 
      newName = [newName stringByAppendingPathExtension:extension]; 
     } else 
      CCLOGWARN(@"cocos2d: WARNING Filename(%@) already has the suffix %@. Using it.", name, suffix); 
    } 

    NSString *ret = nil; 
    // only if it is not an absolute path 
    if(! [path isAbsolutePath]) { 

     // pathForResource also searches in .lproj directories. issue #1230 
     NSString *imageDirectory = [path stringByDeletingLastPathComponent]; 

     // If the file does not exist it will return nil. 
     ret = [self pathForResource:[newName lastPathComponent] 
                ofType:nil 
               inDirectory:imageDirectory]; 
    } 
    else if([fileManager_ fileExistsAtPath:newName]) 
     ret = newName; 

    if(! ret) 
     CCLOGINFO(@"cocos2d: CCFileUtils: file not found: %@", [newName lastPathComponent]); 

    return ret; 
} 

-(NSString*) fullPathFromRelativePath:(NSString*)relPath resolutionType:(ccResolutionType*)resolutionType 
{ 
    NSAssert(relPath != nil, @"CCFileUtils: Invalid path"); 

    CCCacheValue *value = [fullPathCache_ objectForKey:relPath]; 
    if(value) { 
     *resolutionType = value.resolutionType; 
     return value.fullpath; 
    } 

    // Initialize to non-nil 
    NSString *ret = @""; 

#ifdef __CC_PLATFORM_IOS 

    NSInteger device = [self runningDevice]; 

    // iPad HD ? 
    if(device == kCCiPadRetinaDisplay) { 
     ret = [self getPath:relPath forSuffix:iPadRetinaDisplaySuffix_]; 
     *resolutionType = kCCResolutioniPadRetinaDisplay; 
    } 

    // iPad ? 
    if(device == kCCiPad || (enableFallbackSuffixes_ && !ret)) { 
     ret = [self getPath:relPath forSuffix:iPadSuffix_]; 
     *resolutionType = kCCResolutioniPad; 
    } 

    // iPhone HD ? 
    if(device == kCCiPhoneRetinaDisplay || (enableFallbackSuffixes_ && !ret)) { 
     ret = [self getPath:relPath forSuffix:iPhoneRetinaDisplaySuffix_]; 
     *resolutionType = kCCResolutioniPhoneRetinaDisplay; 
    } 

    // If it is not Phone HD, or if the previous "getPath" failed, then use iPhone images. 
    if(device == kCCiPhone || !ret) 
    { 
     ret = [self getPath:relPath forSuffix:@""]; 
     *resolutionType = kCCResolutioniPhone; 
    } 

#elif defined(__CC_PLATFORM_MAC) 

    *resolutionType = kCCResolutionMac; 

    ret = [self getPath:relPath forSuffix:@""]; 

#endif // __CC_PLATFORM_MAC 

    if(! ret) { 
     CCLOGWARN(@"cocos2d: Warning: File not found: %@", relPath); 
     ret = relPath; 
    } 

    value = [[CCCacheValue alloc] initWithFullPath:ret resolutionType:*resolutionType]; 
    [fullPathCache_ setObject:value forKey:relPath]; 
    [value release]; 

    return ret; 
} 

-(NSString*) fullPathFromRelativePath:(NSString*) relPath 
{ 
    ccResolutionType ignore; 
    return [self fullPathFromRelativePath:relPath resolutionType:&ignore]; 
} 

#pragma mark CCFileUtils - Suffix (iOS only) 

#ifdef __CC_PLATFORM_IOS 

// XXX: Optimization: This should be called only once 
-(NSInteger) runningDevice 
{ 
    NSInteger ret=-1; 

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    { 
     if(CC_CONTENT_SCALE_FACTOR() == 2) 
      ret = kCCiPadRetinaDisplay; 
     else 
      ret = kCCiPad; 
    } 
    else 
    { 
     if(CC_CONTENT_SCALE_FACTOR() == 2) 

      if (([[UIScreen mainScreen] bounds].size.width == 640) || ([[UIScreen mainScreen] bounds].size.width == 1136)) 
      { 

       ret = kCCiPhone5Display; 

      } else { 

       ret = kCCiPhoneRetinaDisplay; 

      } 
     else 
      ret = kCCiPhone; 
    } 

    return ret; 
} 

-(NSString *) removeSuffix:(NSString*)suffix fromPath:(NSString*)path 
{ 
    // quick return 
    if(! suffix || [suffix length] == 0) 
     return path; 

    NSString *name = [path lastPathComponent]; 

    // check if path already has the suffix. 
    if([name rangeOfString:suffix].location != NSNotFound) { 

     CCLOGINFO(@"cocos2d: Filename(%@) contains %@ suffix. Removing it. See cocos2d issue #1040", path, suffix); 

     NSString *newLastname = [name stringByReplacingOccurrencesOfString:suffix withString:@""]; 

     NSString *pathWithoutLastname = [path stringByDeletingLastPathComponent]; 
     return [pathWithoutLastname stringByAppendingPathComponent:newLastname]; 
    } 

    // suffix was not removed 
    return nil; 
} 

-(NSString*) removeSuffixFromFile:(NSString*) path 
{ 
    NSString *withoutSuffix = [removeSuffixCache_ objectForKey:path]; 
    if(withoutSuffix) 
     return withoutSuffix; 

    // Initial value should be non-nil 
    NSString *ret = @""; 

    NSInteger device = [self runningDevice]; 

    if(device == kCCiPadRetinaDisplay) 
     ret = [self removeSuffix:iPadRetinaDisplaySuffix_ fromPath:path]; 

    if(device == kCCiPad || (enableFallbackSuffixes_ && !ret)) 
     ret = [self removeSuffix:iPadSuffix_ fromPath:path]; 

    if(device == kCCiPhoneRetinaDisplay || (enableFallbackSuffixes_ && !ret)) 
     ret = [self removeSuffix:iPhoneRetinaDisplaySuffix_ fromPath:path]; 

    if(device == kCCiPhone5Display || (enableFallbackSuffixes_ && !ret)) 
     ret = [self removeSuffix:iPhone5DisplaySuffix_ fromPath:path]; 

    if(device == kCCiPhone || !ret) 
     ret = path; 

    if(ret) 
     [removeSuffixCache_ setObject:ret forKey:path]; 

    return ret; 
} 

-(BOOL) fileExistsAtPath:(NSString*)relPath withSuffix:(NSString*)suffix 
{ 
    NSString *fullpath = nil; 

    // only if it is not an absolute path 
    if(! [relPath isAbsolutePath]) { 
     // pathForResource also searches in .lproj directories. issue #1230 
     NSString *file = [relPath lastPathComponent]; 
     NSString *imageDirectory = [relPath stringByDeletingLastPathComponent]; 

     fullpath = [bundle_ pathForResource:file 
                ofType:nil 
               inDirectory:imageDirectory]; 

    } 

    if (fullpath == nil) 
     fullpath = relPath; 

    NSString *path = [self getPath:fullpath forSuffix:suffix]; 

    return (path != nil); 
} 

-(BOOL) iPhoneRetinaDisplayFileExistsAtPath:(NSString*)path 
{ 
    return [self fileExistsAtPath:path withSuffix:iPhoneRetinaDisplaySuffix_]; 
} 

-(BOOL) iPhone5DisplayFileExistsAtPath:(NSString*)path 
{ 
    return [self fileExistsAtPath:path withSuffix:iPhoneRetinaDisplaySuffix_]; 
} 

-(BOOL) iPadFileExistsAtPath:(NSString*)path 
{ 
    return [self fileExistsAtPath:path withSuffix:iPadSuffix_]; 
} 

-(BOOL) iPadRetinaDisplayFileExistsAtPath:(NSString*)path 
{ 
    return [self fileExistsAtPath:path withSuffix:iPadRetinaDisplaySuffix_]; 
} 

#endif // __CC_PLATFORM_IOS 


@end 
+0

ps:不要忘記備份... – renevdkooi

+0

沒關係 - 它沒有工作。我忘了一些事情。我會調整它並重新發布它。 – renevdkooi

+0

對不起,發佈這麼多,但只是檢查後的cocos2d網站,有一個新的版本支持iPhone 5 – renevdkooi

0

所有的你的建議很好的解決方案,但會有某種形式的命名約定如@ 2x和分別ratina顯示器和iPhone 5推出圖像H + 2倍的。

感謝 馬諾