Multiple screen resolution support in cocos2d v3? - ios

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

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.

Is it possible to use non-retina graphics on retina?

I got non retina graphics from a graphic designer to use with an app. The splash screen has a resolution of 400x640. And yet I am supposed to make a universal iphone 5 and ipad app using this graphics. It is in a .jpg file.
My question is, is it possible to use such low resolution images (400x640) on a retina iPad which requires 1536x2048 pixel images? Or should I get images of proper resolution?
You can see on the Apple's developer page that you must meet some graphic requirements for you app. If it's possible to ask for proper resolutions I believe it would be the best.
You can find more information here to pass it to your graphic designer
You can also read here more exactly what is required and what not if you want to get your app in the store
The aspect ratios of the images are different for a start.
Also, IIRC, if you don't have a default image that is 568 points tall, then your app will run letterboxed on 4 inch phone screens.

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.

iOS- Including different image sizes for different display sizes

I am new to iOS programming and programming in general so this will probably be a fairly easy question to answer for someone who is experienced.
I am making a game using sprite kit and I need to include different background image sizes for the different retina display sizes on the iPhone 4 and 5. I am using a graphics package to create the images in .png format then adding them into the project, the issue I have is that, if I make a 640x1136 size image, it works on the 5, and if I use a 640x960, it works fine on the 4 but leaves blank space around the edge on the 5. (I am running it on the simulator)
If I include two identical images with different names, one for each device, how can I load the right one in? Do I only need high resolution image and can use some code to change how it loads the image in, so that it covers the whole screen without pixelation or loss of quality on both devices?
Any help or advice is appreciated. I apologise if this is a simple question, thanks for your time.
Note:
I found out plenty on the internet about using the #2x suffix for high resolution images, but that's not what I'm looking for. I know how to code for different resolutions, just not two different screen sizes with the same resolution, if that makes any sense.
If you're on iOS 7 SDK which you most likely are, make use of the .xcassets catalogue. It has options for different screen sizes, put the different versions of your image there. And then load image in code.

What resolution do I need to make images for universal iOS apps in?

I am making a Universal app on xCode 4.4, using Storyboards. I am making the images for this app in Photoshop. I want to make a background image that fills the whole screen.
What I want to know is:
What resolution do I make the images?
Do I need 1 for iPad and 1 for iPhone, or more?
How do you make it work with the iPhone 5 as well?
You might need up to 10 background images:
There's the retina iPad: 2048x1536, non retina iPad and iPad Mini: 1024x768, retina iPhone: 640x960, non-retina iPhone: 320x480 and the new iPhone 5 (retina only): 640x1136.
That's 5. If you want to support both landscape and portrait, then you have 10 combinations.
PS: If you decide to keep the status bar visible (as most apps do), then reduce the height with 20 pixels (40 pixels for retina displays). That's how much room is needed for the status bar.
You should consider the approach of using only one image. The user experience of most apps is poor if you dont respect the available canvas size.
And you might want to focus special areas of your artwork to the user.
I would propose you to implement different scenarios at least for iPad and iPhone.
The resolution itself is described within the specs. So use one for iPhone and one for iPad, the different logos are posted in two resolution, with a postfix #2x or for the new Appstore dimensions with another prefix, but all these details are within the specs.
My experience is that in most cases you have to organise the user interface separately in order to provide a good user experience.

Resources