Iphone 5 game resolution - iphone

I have a developer working on a game for me for ios for iPhone 5. He stated the resolution we must use for the game is 320 x 568, but the iphone 5 has a resolution of 640 x 1136 and he stated that this is the resolution for the graphics and not the game leveling design. The game is a 2D maze game.
I am still learning, so any help would be greatly appreciated. Which resolution is the correct resolution? Why is it half of what apple states?
Thanks in advance

Here's the story. When Apple introduced the iPhone 4, it introduced the "Retina Display". That is, the iPhone 4 had a screen with twice as many pixels on it than the previous iPhones. So to compensate, Apple came up with the screen points system. It works like this:
-On non-retina devices, 1 point = 1 pixel
-On retina devices, 1 point = 2 pixels
-On any device, the programmer's coordinates are done in points.
-On any device, the art assets should be done using pixels
Example: I have a 200x200 pixel image used on retina devices. When I load the image into a view, the size of the view is 100x100 points.
In order to make sure your image is loaded properly, you have to use the #2x suffix. If you have a 200x200 pixel image "myImage.png", it will be loaded as 200x200 points and will be scaled up on retina devices. If instead you name the image "myImage#2x.png", instead it will interpret the image as 100x100 points, and will scaled down on non-retina devices. You can also have two versions of an image (Apple recommends 2 images although it isn't strictly necessary). If you have both 100x100 pixel "myImage.png" and 200x200 pixel "myImage#2x.png", it will interpret them as two versions of the same image, and will use the #2x one on retina devices and the other one on non-retina devices. In both cases, the image will be interpreted as 100x100 points.
You might also want to take a look at Apple's High Resolution Guide.

Related

What are pixels and points in iOS?

from UIImage reference:
#property(nonatomic, readonly) CGSize size
The dimensions of the image, taking orientation into account.
Discussion
In iOS 4.0 and later, this value reflects the logical size of the image and is measured in points. In iOS 3.x and earlier, this value
always reflects the dimensions of the image measured in pixels.
What's the difference between pixels and points in iOS?
A pixel on iOS is the full resolution of the device, which means if I have an image that is 100x100 pixels in length, then the phone will render it 100x100 pixels on a standard non-retina device. However, because newer iPhones have a quadrupled pixel density, that same image will render at 100x100 pixels, but look half that size. The iOS engineers solved this a long time ago (way back in OS X with Quartz) when they introduced Core Graphics' point system. A point is a standard length equivalent to 1x1 pixels on a non-retina device, and 2x2 pixels on a retina device. That way, your 100x100 image will render twice the size on a retina device and basically normalize what the user sees.
It also provides a standard system of measurement on iOS devices because no matter how the pixel density changes, there have always been 320x480 points on an iPhone screen and 768x1024 points on an iPad screen.*
But at the same time, you can basically disregard the documentation considering that retina devices were introduced with iOS 4 at a minimum, and I don't know of too many people still running iOS 3 on a newer iPhone. But if such a case arises, your UIImage would need to be rendered at exactly twice its dimensions in pixels on a retina iPhone to make up for the pixel density difference.
*Starting with the iPhone 5, the iPhone's dimensions are now no longer standardized. Please use the appropriate APIs to retrieve the screen's dimensions or use layout constraints.
The Ultimate Guide To iPhone Resolutions
These guys did an awesome job, take a look here — The Ultimate Guide To iPhone Resolutions.
Using data from http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions I set up the formula sqrt(pointWidth^2+pointHeight^2)/diagonalInches to figure out how many points each phone displayed per inch.
Results:
iPhone 2G, 3G, 3GS, 4, 4s = 164.825201164068082 Points Per Inch
iPhone 5, 5s = 162.9846618550346903
iPhone 6 = 162.8061416117083255
iPhone 6 Plus = 153.535954278463216
As you can tell a point is roughly the same size on each phone. Using the same webopage, you can set up the same formula with the pixel values, and you'll notice large irregularities due to higher pixel densities on the newer phones.
iOS pixels, points, units
We should review them in context of
coordinate systems
absolute and relative positioning
Differences
pixels(absolute) - pixel-based coordinate systems of current screen. Is used in very specific cases. For example CGImage (The width/height, in pixels, of the required image), CGContext
points(virtual pixels, logical pixels)(absolute) - default Point-based coordinate systems. It is a kind of density independent pixel - dp in Android.
units - unit coordinate systems(relative). From 0.0 to 1.0. For example CALayer.anchorPoint
[iOS Frame vs Bounds]

Use only retina images in cocos2d

I am using 2 images: image.png and image-hd.png and it works fine for retina and non-retina too.
But what I want to do now is to remove all non-retina images and leave only retina images. I heard that a non-retina device will scale the image down itself. I tried it but it didn't work :( How I do this? What name should I give to the image that it will show picture its actually size on retina and for non-retina will be scaled down?
No, Retina images are not scaled down automatically.
Only using Retina images and using them scaled down on standard resolution display devices is a bad idea.
Non-Retina devices have far less memory than Retina devices, but you're forcing them to load the Retina resolution images. In other words: device has half the memory, but is forced to load images that consume four times as much texture memory as need be.
Non-Retina devices have slower GPU & CPU. But you're forcing them to work on four times the number of pixels. Performance suffers.
You probably need to scale it down manually. I'm not sure if thats the best idea.
But I think you can just scale down the images to 0.5 if in retina device.
About images, its important to remember that each image is taking memory according to the size of the next power 2 dimensions. Which means that 20X20 pic will take the same memory as 32X32, and 130X260 will take 256X512.
So sometimes just handling your image sizes better or using something like Sprite Sheet.

High resolution images and the retina display

Am a newbie to iOS App development and to design. I was wondering about these 2 questions:
can I create a high-resolution image & use it for all the devices (be it retina or non-retina)? (why should one create a low-resolution image intentionally for a non-retina device? why can't everything be simply high-resolution?) ... I hope it isn't a dumb question!
And what do we exactly mean by 'high-resolution' here? '1024pixels X 1024pixels' ? how high is 'high'' really for a retina display?
Any help please?
"High Resolution" means twice the pixels in each dimension on iOS (and OSX). So if you have an image that is 23x10 pixels on a non-retina display, the high resolution version of it must be 46x20 pixels in size.
If you name your high resolution images like this: lowResImageName#2x.png, the system will automatically choose the high res image on retina devices.
As others have said, you use special low-res images to maximize quality (because you can choose to leave fine details out of a low-res image, etc.) and minimize memory footprint (because the non-retina variants have had half the RAM of the retina versions so far).
It also helps to think in non-retina pixels, because one non-retina pixel equals one "display point", the unit in which iOS measures sizes.
iOS devices' resolution is as follows:
standard retina
iPhone, iPod Touch 320 x 480 640 x 960
iPad 768 x 1024 1536 x 2048
iPhone 5 - 640 x 1136
Why create a low-resolution image? Because it will automagically be used on non-retina devices, saving memory.
For some images that will work just fine, but for certain ones (if your image has some fine text for example), they will come out looking jagged or distorted when scaled down automatically. There may also be cases when you want something displayed differently(I've had occasional images with cool gradient effects that just don't look right on a low res device, so I've had to remove some detail in the low res image to make it look okay).
The other answer is also correct in that if you allow for both cases, low res devices will only load the low res images into memory, so the app will be using less memory. This is only an optimization for those cases, but it is still helpful since typically you can assume that the low res devices will have less memory to begin with since they are older.
Retina graphics, the high resolution graphics you are mentioning, should be double the point values for width and height. What I mean by that is, on all iPhone-sized devices, the size of the screen is 320 points by 480 points. On non-retina devices, translates to 320 pixels by 480 pixels. On retina devices, this translates into 640 pixels by 960 pixels. Everything is double in both the horizontal and vertical directions.
What this means, is you should have two versions of all your image assets. So if you have image that you want on the screen that is 44 points wide by 44 points tall, you should have two images ... Image.png which will be 44 pixels by 44 pixels, and Image#2x.png which will be 88 pixels by 88 pixels (for retina devices, this is what the #2x represents).
Why have two versions, and not just the high rez version? Because it takes processing power to 'compress' the larger version into a smaller version. It's much easier to just already have the lower resolution version, and you are saving valuable memory.
The first question was answered by H2CO3. You safe memory on old devices (think of iPhone 3G, many current Apps are terribly slow, yet well-coded apps still work fine)
What does high-resolution mean?
E.g. on a non-retina device you can show some example.png of 300x200 pixels using [UIImage imageNamed:"example.png"].
High-res would mean, you had an additional example#2x.png of 600x400 pixels, i.e. double size. Then you're app size is bigger, both devices have appropriate graphics but you save memory on the old device (Which would have to allocate 4 times the memory with no added improvement for the user, because it still has only a 300x200 pixel-display-space for a 600x400 pixel image).

Desiging Websites for Retina style devices: What dimensions should you use when designing?

The dimensions of the iPhone is 320x480
The dimensions of a Retina iPhone is 640x960
When designing a design for a retina device, do you set the size of your document to 320 x 480 or 640 x 960?
I would have thought you would have set the size to 320 x 480.
The reason for this is that although a retina device has more pixels, these are still being displayed on a 3" screen size. If you did set your size to 640 x 960, then when viewed on a retina display, all the text would be small, as although there are more pixels, the screen isn't physically bigger.
Is that correct?
UPDATED: Do you also use 320 x 480 as a base size for CSS (see comments below)
Yes, that's correct. I'm an iOS developer, not a web designer, but in iOS devices you specify everything in points (which is one pixel on a non-retina device, and a 2x2 pixel block on a retina device) so everything is the same size. The extra pixels on the retina display simply make everything look better.
You can get away with smaller text on a retina screen since you have more detail, but accessibility wise that's not a good move, since lots of people can't then see your text without zooming, whatever kind of display they have.

iphone 4 Simulator reporting 480x320 as the screen size?

I am debugging an application using iPhone 4 Simulator. I have selected it from the simulator menu (device = iPhone 4). When I run the app, the screen size is reported as 480x320 !!??
Is there something I have to modify on this app of mine (originally built for 3G/3gs) in order to make it run on iPhone 4 (yes, I have recreated all artwork as 960x640 and the artwork is on the bundle, but it is scaling it down to half the size... because it is running on 3G/3GS mode, instead of hi res).
running
CGRect cgRect =[[UIScreen mainScreen] bounds];
will result in (0,0,480,320).
Any clues?
thanks for any help.
Recommended read: http://developer.apple.com/iphone/library/documentation/iphone/conceptual/iphoneosprogrammingguide/SupportingResolutionIndependence/SupportingResolutionIndependence.html
One point does not necessarily
correspond to one pixel on the screen.
A sample project, download here.
The iPhone is making the move into resolution independence. This means that things aren't measured in pixels, but in points. Points don't always correspond to pixels.
The screen size of the iPhone 3GS (and previous) is 480x320, in both points an pixels. They correspond on these devices, but in newer devices (like iPhone 4) they do not.
The iPhone 4's screen size is 960x640 in pixels, but its logical screensize is still 480x320 in points.
This allows you to keep your frame, point and size values in their original values and still support larger resolution devices.
On iPhone 4 you need to have #2x somewhere in the name of the image file and it will be used automatically on the higher resolution devices.
When #2x images are loaded, they are loaded as their original resolution, but their size property is halved to be able to work with the logical point measurments.
For instance, an image with an original size of 960x640 will report its size as 480x320 when it's asked for.
instead of bounds use currentMode
CGSize pixelBufferSize = [[[UIScreen mainScreen] currentMode] size];
you will get actual resolution