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

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).

Related

iOS - blur and buggy retina graphics on older devices running iOS7

I have been developing an app for iPad and was testing i on iPad 3 and iPad air with no problems at all. When i tried same app on iPad 2 the images were blur and some of them were not displaying properly even some were half visible half not visible.
As per my knowing the iOS7 only apps do not need non-retina graphics so i am using only Retina Graphics. So i tried using Asset Catalog too but same was the result.
Strangely when i use image#2x.png in xib it displays fine but do not show image in xib and when i use image.png it is displayed in xib but same issue when run on the device.
What i need to do to show images in xib too and would run fine on device?
Fisrt You MUST provide non-retina graphics in the asset catalog. You should understand that bigger images on old devices provides bigger memory and performance impacts.
You must pay attention also on odd measure, because if some geometric frames calculation results in decimal point such as 23.5 1.5 you are going to have antialiased elements in your interfaces.
You can avoid that wrapping frames into CGRectIntegral.

Multiple screen resolution support in cocos2d v3?

I am little confused with cocos2d v3's support for multiple screen resolutions. If I use CCSetupScreenMode: CCScreenModeFlexible, what should be the default resolution of the image that I provide?
Currently, I have provided assets for all the iOS device resolutions along with suffixes and the correct images are loaded on iPhone "3.5inch" and iPad. However, the "-568h#2x" suffix for iPhone "4 inch" is not working fine. Am i using the wrong suffix?
I would like to avoid the need to use macros to determine which device the game is running on and load the images accordingly.
Thank you for your time!
The ScreenMode only defines if the screen scales up with the device size or not.
The fixed screen mode provides you with a stage that has a safe area and an unsafe area but the complete stage always has the same size.
In the flexible screen mode the root node of your scene will resize with the actual screen size, so you have to deal with dynamic sizing.
You can read more about the screen modes, image sizes and how to design a game for multiple screen resolutions in our tutorial.
In Cocos2D the suffixes are different from the ones UIKit uses. The suffixes are:
-ipad
-ipadhd
-hd
-iphone5hd

Hardware specific atlas with Sprite Kit is blown up on iPad

Watching talk 503 "Designing Games with Sprite Kit" from WWDC 2013, they say that one of the benefits of texture atlases is that you only need to drop a folder to XCode and it generate hardware specific atlases for different devices (OSX, iPhone, iPhone Retina, iPad...)
Is that correct?
I'm dropping a folder with a frames for a sprite animation and though it appears the same size on iPad 2 and iPad retina, its size is twice the correct size, and, of course, in the iPad retina the image is pixelated.
What am I doing wrong?
Short answer: Append a #2x suffix to each of your retina pngs inside your .atlas folder (example: heroimage#2x.png) - these will be then displayed correctly on Retina devices. This enables the retina display to calculate the ratio of pixels to points correctly (otherwise they'll appear to be double their size on Retina).
Files with the same name, but without the #2x suffix, will be the non-retina counterpart.
A slightly more complex answer: if you need to differentiate among more devices, iPhones and iPads, you can use the #2x~ipad suffix and #2x~iphone for the Retina iPad and iPhone, respectively. However, there have been reports of bugs here.
What was meant at WWDC is probably the fact that if you place images for different devices (with different suffixes) in your texture atlas, then the generated collective atlas images are indeed separate for each device. As it says in the iOS Developer Library:
Images for the same device are kept together—for example, all iPhone
images are in one file (~iphone.1.png), and all iPad images are in
another file (-ipad.1.png).

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.

Is there a way to generate a more detailed image?

I have an app that I'm testing on my macbook that generates images. They are fairly low resolution. Is there a way to make the images of a higher resolution, or do I have to go to the iPad to generate there? I have the following code that I was hoping would do the trick, but it didn't seem to do anything :
self.imageView.contentScaleFactor = 2.0;
Thanks in advance!
When doing screen snapshots, make sure the simulator's "Hardware" - "Device" settings is for a retina device. Then either the simulator's "File" - "Save Screen Shot" or doing it programmatically will yield a retina-resolution image (regardless of the setting for "Window" - "Scale" in the simulator). Just make sure you've configured the simulator to simulate "Retina" hardware.
When you generate these retina-quality images, though, you don't have the appearance of the physical device (which is nice to have when going to print). If you want the appearance of the physical device, you can marry these screen snapshots with the "Apple Product Images" on the Marketing Resources page (you need Photoshop to do this).
Ultimately, though, you're limited to the resolution of the digital assets in your app. For example, if you don't have retina-quality digital assets (e.g. only 320x480 resolution images), then it will look horribly pixelated when you print it.
And even full retina resolution screen snapshots will look a little pixelated when you print. If you scale your 640px wide screen snapshot in print, if it's much more than 2-3 inches wide when you print, you'll start to notice the pixelation and there's not a lot you can do about that (without cheating in Photoshop and replacing images with higher resolution assets).

Resources