2012-11-06 56 views
5

我使用cocos2d的:如何添加在cocos2d iPhone5的支持

-hd.png for iPhone HD 
-ipad.png for iPad. 
-ipadhd.png for iPad HD. 

就像我們需要使用的iPhone 5這裏面延伸?另外如何在cocos2d中啓用iPhone 5支持?

更新1:輕鬆,我們可以支持的iPhone5這樣

#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES) 

#define TEX_GAME_BG (IS_IPHONE5) ? (@"bg-whd.png") : (@"bg.png") 

mBG1 = [CCSprite spriteWithFile:TEX_GAME_BG]; 

最新通報2:使用一般功能...把這個cocos2d.h或任何共同文件

static inline NSString *i5res(NSString * data) 
{ 
    if(IS_IPHONE5) 
    { 
     return [data stringByReplacingOccurrencesOfString:@"." withString:@"-whd."]; 
    } 

    return data; 
} 
//usage 
CCSprite *bg = [CCSprite spriteWithFile:i5res(@"bg.png")]; 

更新3: Cocos2d現在也支持iphone5。 -iphone5hd

imageName-iphone5hd.png for iPhone 5 HD. 

回答

3

沒有擴展名在cocos2d iPhone5的尺寸的圖像。如果你需要使用這樣的圖像,你將不得不自己加載它們。

也許還想起如何完全避免圖像。如果您使用的是背景圖片,也許您可​​以使用平鋪圖片代替?

要啓用iPhone 5支持與任何iOS項目相同,只需將[email protected]啓動圖像添加到您的項目。

+0

ok..thx的信息。 – Guru