Hardware specific atlas with Sprite Kit is blown up on iPad - ios

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

Related

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.

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.

ios, publish different build per device

Google Play allows different apks per screen density, does Apple Store support this?
I'm sure the info is somewhere, but all I find when I search are people asking how to develop one app to support all devices.
I know how to do that already, but this specific (top secret) project will be 1000 times better if I can release one super optimized version for each screen resolution... but I'll settle for density or device (generation and type) if needed.
I don't have access to XCode (no Mac) to check options currently.
Bonus points: If possible, is Apple going to frown on this and possibly reject my app because of this?
This can't be done. If your app supports the iPhone then it must support both 4" and 3.5" inch iPhones. If it supports only iOS 7 then you can avoid non-retina devices because only retina devices can run iOS 7.
But if you support the iPad you must support both retina and non-retina.
You can have one app (Universal) that does it all or you can have separate iPhone and separate iPad apps. But the iPhone app must support both sizes and possibly both types (retina and non-retina) of screens. And the iPad app must support both types of screens.
Apple won't accept apps that don't support the differences.
It should also be pointed out that in the Interface Builder part of Xcode, you setup the UI with points and not pixels. So, for an iPad, when you place a button, you do not have to specify retina or not. On a Retina screen a point is 2x2 pixels and on a non-retina screen a point is 1x1 pixels. Also, with image assets, you have a single image asset you ask for in code, but you add multiple copies of the image in the image assets. Like the retina and non-retina copies. If you have an image named cat.png, for retina this would be cat#2x.png and for non-retina it would be cat.png. But, in code or the inspector you would reference it with imageNamed:#"cat" and Objective-C is designed to handle the rest.

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

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.

Resources