cocos2d 2.0 not loading ipad graphics - ipad

I have the suffixes for iPad and iPad retina screen devices defined as -ipad and -ipadhd for my ccFileUtils for my universal app, and I also have all my graphics included in the correct size for iPad and the retina iPad with the correct suffixes... However whenever I run the app in the simulator it shows the standard without suffix images :/ Like so...

This was a silly error nothing to do with the coding in the end. I checked the file-type of the image in question (Background-iPadhd.png) and it turned out even though it has the extension .png it was in fact a .psd file. It's possible to accidentally save files with a .png extension but in the .psd format if you write the filename as xxx.png but leave the format as .psd when saving from photoshop.

Related

Assets.xcassets - Universal not working

I am using Universal for Assets.xcassets in the hopes that I only have to create 3 different sizes for each image I use. But, despite Assets.xcassets telling me that my images are Universal in the Attributes Inspector, when I test on my iPad, the images are blurry and aren't as sharp as they are on my iPhone, making me question why there is a Universal option.
I've double checked all my images and they are all correctly sized.
My questions:
In the Attributes Inspector, under Universal, there are iPhone and iPad options. In order for my iPad to provide crystal clear images, should I use the iPad option?
And if I should: What's the point of the Universal option if it doesn't really do its job?
Also if I should: What size images do I use. The iPad option gives me the options of 1x and 2x size images. So, should the size of the 1x image for iPad be the same size as 1x image for Universal?
Thanks in advance.
Universal merely means that this app will run on iPad and iPhone natively. Thus the devices on which your app might run can have a single-resolution, double-resolution, or triple-resolution screen.
If you have checked Universal, accordingly, you should see three slots:
Your job, therefore, is to make three versions of your image, sized in proportion. If the 1x is 100x100, the 2x should be 200x200 and the 3x should be 300x300. The version in the appropriate slot will be used at runtime in accordance with the screen resolution of the device we're running on.
The asset catalog does not do any image sizing for you. You have to do it beforehand. (I find Graphic Converter a nice utility for this purpose.)
You could just supply a 3x image and allow the runtime to size down for you, but this is a waste of memory; Apple specifically advises against this in one of the WWDC 2016 videos. So just bite the bullet and make all three image sizes yourself.
Finally:
when I test on my iPad, the images are blurry and aren't as sharp as they are on my iPhone
Hmm, the only reason I can think of for this is that your app is not running natively on the iPad, but is an iPhone app running in "emulation mode" on the iPad. If that's the case, nothing you can do is going to make it look really good. It would be better to write your app as a true Universal app. That is a setting that you make when you create the project initially (though it can be changed later by editing the app target).

Non retina images – must I add them to xcode?

Because I made app (iphone) myself, with 200 images, I want not using non retina images.
It may be for me big problem to resize images for non retina display.
I don't have non retina display iphone, to test it.
Must I add non retina images to xcode, or not?
If I don’t add them, must I add “#2x” to all images for retina?
I tried my best to find answer for my question but there was no clear answer.
Thx for answers.
I thing it will be better make non retina display images, than buy non retina device for testing how it looks.
I have another question:
Button background needs #2x images and non retina display background images?
You must add non-retina images if the platform your targeting includes non retina devices (e.g. iOS 6 and earlier or iOS 7 iPad). If you do not, non-retina devices may not render your app correctly.
If you are not targeting a platform that supports non-retina devices (Eg iOS 7 iPhone), you may omit non-retina images. Your retina images will still need the "#2x" suffix in the file name for the system to find them.
I read somewhere that if you do not include non-retina images, the iOS will use the #2x images, scale them on the fly to non-retina sizes, but that may affect performance. Make sure you test on at least one non-retina Device to make sure it works.
This should not be too much of an issue. Test your app on the simulator using non retina and make sure your images are showing up properly. Your images should scale and won't cause a problem. It would be better if you could have both retina and non retina images but not a game beaker.

How does JSTileMap handle retina and ipad/iphone tile maps?

I have created a basic tilemap using Tiled. I am using JSTileMap with SpriteKit to get the map in the scene. As I understood, JSTileMap (rather SKTexture) handles the retina and different devices automatically. I have not been able to produce good results so far, here is my setup:
I have one .tmx file created at a base resolution using map.png as it's tile set. The .tmx is present in the project but I purposely did not add map.png (I do not want to support non-retina iPhones).
In the project I only added the following .png's:
map#2x~iphone.png (retina iPhones, using 48x48 tiles)
map~ipad.png (non-retina iPads, using 48x48 tiles)
map#2x~ipad.png (retina iPads, using 96x96 tiles)
Here are the results I get (after clean builds and reset content and settings on simulator):
Retina iPhone - tiles is wrong spots
iPad - no tilemap displayed, JSTileMap has parsing error
Retina iPad - tiles in wrong spots
If I use just a plain vanilla map.png (with 48x48 tiles):
Retina iPhone - tile map displays well but too large of course
iPad - tile map displays perfectly
Retina iPad - tile map display perfectly and is scaled.
I know I could just use a 24x24 tile map.png and apparently it will scale everything. I would prefer not to use scaled tile sets as the quality would suffer.
Thanks in advance.
E
I was able to narrow down that SKTexture ignores the ~ipad file extension for the #2x file extension. This only created more headaches in trying to build a tile map system for iPhone retina, iPad, and iPad retina.
I have decided to avoid the problem all together. I am not using a universal app in my project now. I have a iPhone project and a separate iPad Project. This way all I need to do to work with Retina is the #2x file extension in each project.
This does fully work (much easier). A word to the wise to those only building for retina iPhones... half your tile height and width sizes in the .tmx files, otherwise you will have a great time trying to deal with the content scaling.
Since you're using Sprite Kit and that requires iOS 7 there's actually no non-Retina iPhone to target anyway.
The thing in that instance is that you can't use #2x suffixed images without providing the same image without the #2x suffix. So the solution may be as simple as supplying the Retina iPhone images without the #2x suffix. You likely don't even need the ~iphone suffix either because the other two types of assets will only be used by the iPad devices.
This is based on an answer to a different question. I haven't personally verified it.

Retina Display images looks fuzzy and blurred. No Reason why?

I am a Cocos2d game developer. I am developing a game using retina display images.
I have created texture files with and without HD suffix using zwoptex.
I have added those zwoptex plist texture files in app-delegate like [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:#"Background.plist"];
I have enabled the retina display to YES [director enableRetinaDisplay:YES];.
I have used the png files from the plist wherever i want using ccsprite *background = [CCSprite spriteWithSpriteFrameName:#"sample.png"];.
All those png files which I have included are high resolution images with both sizes 960*640 and 480 * 320. But in no reason the images look blurry and fuzzy when i run the game in simulator or iPhone. Anyone please help me to solve this issue …..
(The following image was posted as an example in a comment.)
cocos2d applies anti-aliasing to sprites by default. You need to turn that off:
[background.texture setAliasTexParameters];
hope this helps.
The screenshot you posted (I took the liberty of adding it to your question) shows that it was taken from the iPhone Simulator and not the iPhone (Retina) Simulator. Therefore it will not use the HD images.
With the iPhone Simulator running go to the Hardware -> Device menu and select iPhone (Retina) as the device. Then restart your app.
Note also that the iPhone Simulator will only render the game with a color depth of 16-Bit, regardless of settings in cocos2d or your Mac. The iOS Simulator renderer is limited to 16-Bit rendering for performance reasons (it only uses software rendering, no hardware acceleration). Only by looking at the game on an actual device can you make judgement calls about image quality.
To test whether the game is actually loading the HD assets or for some reason just loads the SD images, try running it without the SD images. If the game tries to load the SD images it will cause an error. If not, it is loading the HD images and the "blur issue" has a different cause. You could also log which files are loaded by adding a NSLog statement to the CCFileUtil class method fullPathFromRelativePath which performs the file name changes to load -hd images whenever possible.
You'll find that even miniscule amount of scaling or rotation applied to a sprite may have it look blurred, so check if you happen to do that. Any change in blend modes (using ccBlendFunc) could also cause blurred images. Also check that your images are fully opaque (opacity == 255).

Use JPEGs for Launch Images

This is related to Default-Portrait.png for iPad: any way to make the file size smaller?
Is there any way to specify a more efficient file format (like JPEG) for Default-Landscape.png
and Default-Portrait.png?
Yes it's possible to use jpg files as launch images. Just add "Launch image" key with the base filename (e.g. LaunchImage.jpg") to the Info.plist. Then add files to your project such as
LaunchImage.jpg
LaunchImage#2x.jpg
LaunchImage-568h#2x.jpg
and Xcode will pick them up.
However through personal experience I've discovered if you're supporting the larger iPhone 5 screen the App Store expects PNG format and uses the presence of PNG to determine iPhone 5 support and display of iPhone 5 size thumbnails on the store. Using JPG images will not show the app as iPhone 5 optimized in the app store (even though it will work fine on the device) so it is best to stick with PNG.
There is no way to use an image other than a png.
All launch images must be PNG files and must reside in the top level of your app’s bundle directory. Section: App Launch (Default) Images
Update: JPEG images to work and Apple's documentation no longer specifies that the images must be PNG files.
If you use xcassets, then since Xcode 6 you can use JPGs. However Xcode will still not let you drop JPGs into the LaunchImage folder. But you can do it in Finder. Simply drop your PNGs into that folder with Finder and then edit the JSON file changing all .png extensions to .jpg.
I haven't submitted an app to the store using this yet, but it works in the iPhone simulator at least.
Update: Doesn’t work on the device. I’ll leave this answer here anyway so people know that this technique was at least tried so the effort won’t be repeated.

Resources