I have a game in iphone already developed one year back in older version of cocos2d.
Now i want to upgrade the game with both retina and non-retina graphics for all iphone3G,3GS and 4+ devices.
I have used many buttons and CCMenus how can i handle them in code. Do i have to write conditions for every graphic?
Any help or tutorial?
Thanks in advance
No, you dont need to do the conditional coding.... You can have the retina display support bye either un-commenting or adding the below code into your appDelegate.m/.mm file in the applicationDidFinishLaunching
if( ! [director enableRetinaDisplay:YES] )
CCLOG(#"Retina Display Not supported");
Also you need to add "-hd" suffix image files for the retina display of the iPhone.
For cocos2d version 2 you need the "-ipad" & "-ipadhd" files to be present in your Resources folder.
To upgrade the cocos2d version you can follow the steps on this Link.
But cocos2d version 2 supports 3GS and above iPhone.
Hope this information would help you.
As I know, the iOS will do this for you if you name the image file in a correctly way.
ex:
normal screen: banner.png
Retina screen: banner#2x.png
The only thing you need to do is name the higher resolution image by a same name with the lower one and add subfix "#2x"
Related
I would like to know how to include retina images for the iPhone 5 in cocos2d. I already have large images from the iPad version of the game. How do I do that ? Unfortunately there is not very much information on the internet, so I thought I'll ask here. I do not have a working iPhone version of the game yet.
This is built into cocos2d. Use xxx.png for standard resolution image, then provide a xxx-hd.png image and cocos2d will use that high-res version on Retina devices (including iPhone 5).
The file suffixes for iPad are -ipad and -ipadhd for Retina iPads.
My cocos2D app, Forever Afloat, works perfectly fine with all the combinations until you get to iPhone 5 and iOS6!
The app display is all stretched out so that you see only the lower left corner and the rest is off the screen.
Only until you force it to autorotate, does the app begin to display at proper dimensions...
My problems can also be found at this problem cocos2D iOS 6 retina display
They asked the same question.
Any solutions?
Thanks!
cocos2d uses image with image-hd.png and not image#2x.png
Check whether you are using #2x an replace by hd
Use new version of cocos2d and here is image extension.
-wide.png for iphone 5
-widehd.png for iPhone 5 HD
-hd.png for iPhone HD
-ipad.png for iPad.
-ipadhd.png for iPad HD.
There were some issues within the AppDelegate regarding the order of calls that made the display all strange. All I did was move the initalization method to the top and it fixed everything!
I have been looking everywhere for this but with no luck.
How do I prepare my cocos2d based game for bigger 4 inch display of the iPhone 5?
My app is working but i want to enhance it for the bigger 4 inch display.
Cocos2d uses its own suffixes for retina display images. For retina display of the iPhone 4 and 4S it is image-hd.png. Is there a suffix for iPhone 5? How do I accomplish this?
Cheers.
There is no extra file suffix for iPhone 5, after all it's only 176 pixels (88 points) wider. It's treated like a regular Retina phone, hence cocos2d will load the -hd files.
The rest is just about positioning your images depending on the device. The simplest way is to just treat the 44 points on either side as a "dead zone" where no user input can occur and where there's no guarantee the user can see game objects.
Update:
cocos2d 2.1 added the -widehd suffix. It was said that 2.1 final release will have the suffix renamed to -iphone5hd.
In light of future screen sizes I sould personally set and use a -568hd suffix because other phones beside iPhone 5 may have the same resolution. Naming the suffix after a specific iPhone model is a tad short-sighted to say the least.
Add it to AppDelegate:
[CCFileUtils setiPadRetinaDisplaySuffix:#"your suffix"];
[CCFileUtils setiPadSuffix:#"your suffix"];
[CCFileUtils setiPhoneFourInchDisplaySuffix:#"your suffix"];
[CCFileUtils setiPhoneRetinaDisplaySuffix:#"your suffix"];
Not sure why everyone is saying there isn't.
The suffix is -568h for iPhone5/iPod Touch 5th (so the 4 inch retina displays).
The total list:
-hd (iPhone 4/4S, iPod Touch 4th)
-568h (iPhone 5, iPod Touch 5th)
-ipad (iPad 1st/2nd)
-ipadhd (iPad 3rd/4th)
Add this to AppDelegate with your chosen suffix:
if((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) && ([[UIScreen mainScreen] bounds].size.height == 568)) {
[sharedFileUtils setiPhoneRetinaDisplaySuffix: #"-your suffix"];
}
It took me awhile to figure this out, since I'm new to cocos2d. So I thought a recap might be helpful for those like me. In cocos2d 2.1, all you have to do is creating graphics for the target screen sizes and follow cocos suffix naming convention. Note that cocos's suffix convention is not the same as iOS's.
In my case, I have a background image that occupies the full screen. So, I made...
background.png at 480x320 for iPhone
background-hd.png at 960x640 for iPhone retina (3.5")
background-iphone5hd.png for iPhone5 retina (4")
And use the following code to load the image into CCSprite. Cocos will figure out which image to use for you.
CCSprite *background = [CCSprite spriteWithFile:#"background.png"];
background.position = ccp(background.textureRect.size.width/2,
background.textureRect.size.height/2);
[self addChild:background];
For an element like a character that doesn't occupy the full screen, cocos2d will pickup character-hd.png automatically in iPhone5. There is no need to create character-iphone5hd.png version.
You can read more about this in version 2.1 release note at
https://github.com/cocos2d/cocos2d-iphone/wiki/cocos2d-v2.1-release-notes
This is how i did it for cocos2d v2.1-beta4.
In CCFileUtils.h i added:
- (void)setIphone5HDSuffix:(NSString *)suffix;
In CCFileUtils.m:
- (void)setIphone5HDSuffix:(NSString *)suffix
{
[_suffixesDict setObject:suffix forKey:kCCFileUtilsiPhone5HD];
}
In AppDelegate.m:
[sharedFileUtils setIphone5HDSuffix:#"your_suffix"];
And that's enough!
Did you follow the following post, adding the default image for it, named Default-568h#2x.png with a resolution of 1136x640?
How to develop or migrate apps for iPhone 5 screen resolution?
If it does not work, I found this post on cocos2d forum, containing a lot of infos:
iPhone 5 1136 x 640 screen resolution: http://www.cocos2d-iphone.org/forum/topic/39491
Now cocos2d support iPhone wide screen also.
-wide.png for iphone 5
-widehd.png for iPhone 5 HD
I was just playing around with suffixes in Cocos2D 2.1-rc1 and was able to get it to automatically load a iPhone5 file with the "-iphone5hd" suffix, not changing anything in AppDelegate in the sharedFileUtil section of code. Hope that helps, also.
I'm developing a game using cocos2d. It's running now on iPhone and also supports Retina display. With retina i'm using images with "-hd" postfix. Now i want my application to be able to work on iPad using this images. How can i do that ?
PS: I don't have a real iPad and can only use a simulator. I will test the game on my friend's iPad after it will work well on a simulator. Is it possible to use hi-res images with simulator and how to do it?
I'm using cocos2D 0.99.5
inside CCFileUtils.m
inside method name +(NSString*) getDoubleResolutionImage:(NSString*)path
edit if( CC_CONTENT_SCALE_FACTOR() == 2)
to if( CC_CONTENT_SCALE_FACTOR() == 2 || (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad))
this will make the app to load the -hd image when running on ipad, remember to change your app targeted device family to iPhone/iPad.
this will solve the loading of -hd problem for ipad.
but after loading -hd file for ipad resolution, you will also notice that most of your image position should be off alignment, now either you go directly into the cocos2d folder to edit how CCNode,CCSprite,CClabel handle the positioning of thing or you code it in your code checking if its ipad or not.
if you are using CCSpriteBatchNote. this will also cause another problem because you will be reading from the -hd SpriteSheet. so the texture Rect u set to cut need to be double too.
another method is position everything according to winsize. i haven try this method.
I don't exactly understand the question but I will try to answer.
You can technically use the same graphics for the iPad, but they will not look as nice. For one, they will all blurry and pixelated, and two, the iPad has a different screen aspect ratio that the iPhone/iPod Touch. If you do make separate images for an iPad version of your game, it will not be extremely difficult to do. If you want to do this, I suggest posting a new question.
So I'm currently making an app that supports both iphone 3gs and ipad (this is a universal binary app).
What I'm wondering is how will iphone 4 users view my app, will they see it pixelated? will they not see it full screen since my iphone 3gs is on a smaller resolution?
I don't have an iphone 4 yet but I'd rather just release this app as is - just for 3gs and ipad. Is there anything that I must know / any precautions etc? Oh (i just thought of this) is there an iphone 4.0 simulator so i can check out if my app works okay?
Thanks!
Basically any bitmap graphics (PNG files) will look a little blurry on the iPhone 4's Retina display.
The easiest way to fix this is to make double scaled versions (100x100 becomes 200x200) of all your PNG files and add them to your project suffixed with "#2x.png". In other words, MyBitmap.png will become MyBitmap#2x.png. Luckily your code doesn't have to change. On the iPhone 4 the OS will automatically choose a #2x.png instead of the regular one when you do:
UIImage *myBitmap = [UIImage imageNamed:#”MyBitmap.png”];
Xib files will also use the #2x.png if there is one available.
Other than that there's also launch images and Application Icons to worry about. This blog has a good summary.
Yes you can change your device type, by in the simulator pressing: Hardware->Device->iPhone 4 If you don't have it you might want download the latest devevloper tools.
Also you might have to press Window->Scale->100%