I am at the start of a new game. My last game was for the iPhone, and it had to double up for iPad.
Now with the iPhone 5 screen being larger than 4, and iPad and iPad mini, I want to program the game to display the correct size images. Is it possible to design large graphic for iPad and use the same images for iPhone (just display the image smaller when using iPhone 4 etc) or is it best to use two lots of images, iPad version and iPhone version? The problem here would be the size of the app. The App would double the download and install size as the graphics would be quite large, and this isnt something I want to do.
Is it possible to use the same xib for ipad and iphone, and then I could just get the code to detect the screen size and display the game correctly based on that?
Also, I have started the project as Cocos2d with Box2d with the latest download of Cocos2d. It starts off with just the code, should I work from the storyboard instead?
thanks
1) You cannot use single xib file for both iPhone and iPad (programmatically you can but that would screw your app).
2) While doing development using Cocos2D, my experience suggests do not use any xib or storyboard file. Else you will end up in a mess.
3) As far as the question for image size for different iOS devices is concerned, I would suggest you to go with separate images (only typical ones) for different iOS devices. If you have some buttons and simple curve based UI go for CoreGraphics so that you do not need those images. Only use images that are typical ones and use CoreGraphics for rest of the images
Related
I love that Spritebuilder takes the retina iPad image and automatically makes the scaled down iPhone images.
I make one image (ipad retina), And spritebuilder makes the iPhone ones automatically:
But for certain buttons/sprites, I wanted to make both the iPad and iPhone images myself. How do I add custom iPhone AND iPad versions for an image that can be used in the Spritebuilder UI?
Eg. Use one image for iPad (retina), But use another one for iPhone.
Also, how do I add something like an external spritesheet into my Spritebuilder XCode project? (Adding the -hd or -ipadhd suffix no longer works, it just always chooses the one with no suffix) -I heard is has something to do with 'resources-phone'?
If you select an image in SB you can see its preview image in the top half of the file view. Below the image are 4 smaller buttons labelled auto, one for each platform (phone, phonehd, tablet, tablethd).
For instance, select your ipad image, then drag and drop another image to that image's phone and phonehd auto buttons. That way they override the original image when the app is run on a phone or phonehd device.
I started to develop an iPhone app for iOS 7.
Since iOS 7 does not support devices with non-retina display for the iPhone/iPod touch, and it uses high-resolution images on non-retina iPads (iPad 2 and iPad mini) in the iPhone emulation mode, now I think we don't need to provide low-resolution images when developing an iPhone-only app which deployment target is iOS 7.
I thought it's great, but soon I faced a problem when I used a Storyboard; apparently Interface Builder can not display high-resolution images which file names end with #2x.
I feel it's really pity that we have to provide the low-resolution images ONLY for the Interface Builder...
Is there any good workaround for this? Or do we still have to provide low-resolution images if we want to use the Interface Builder?
You are correct that an iOS 7 iPhone-only app is not going to run on any single-resolution devices, so you only need to provide double-resolution images. Do what you have always done in the past: refer to your image as myImage but name the actual image file myImage#2x.png. Even better, use the asset catalog! Place the double-resolution image in the 2x slot and refer to it by the name of that image set. Either way, this will work perfectly both in the storyboard editor and in the running app; in the storyboard editor, the Media Library and things like buttons that have images will display your image's name as myImage.
I'm a newbie of iOS development and I'm confused regarding universal app.
We can use the same code, same xib file for iPhone 4(retina) and previous iPhones, but why we should write two different xibs for iPhone and iPad? What's the difference?
For iPhone and retina iPhone, we use "point" instead of pixel for the coordinate. Why we can't use the similar method for iPhone and iPad?
For some simple apps, it is possible to design your iPhone UI and reuse the same xib file for the iPad. Just select your Target in XCode and copy the Main Interface text from iPhone / iPod Deployment Info to iPad Deployment Info. If you're using a Main Storyboard, copy that too. However, the iPad does not simply scale everything up from the 320*480 / 640*960 iPhone screen to the 768*1024 / 1536*2048 iPad screen. #elgarva correctly says that this would look terrible. Instead, the iPad version makes use of your autosizing masks to resize or reposition each view.
If all of your views can be considered to be left-middle-right or top-middle-bottom, this may work. If you have anything more complicated, you'll need to design a separate iPad interface.
Duplicating your iPhone UI is not just discouraged for aesthetic reasons - iPhones often end up containing a deep and confusing navigation tree for tasks that the iPad can fit on a single screen.
The main reason, is that if you just scale the elements on the UI to fit the larger screen, it wouldn't look nice... and you don't need to do anything for it to work, it automatically does it for you if your app is iPhone only and installed on an iPad (if the user chooses to).
Having a different XIB lets you rearrange your app, and think it so that you can take advantage of the larger screen. You can probably show more information on one iPad view than on 3 different screens on the iPhone... so, your iPhone app could show basic info and expand it when the user taps on it, while your iPad version could show all the information on load, plus extra graphics that look nice but aren't needed, and wouldn't make sense on the iPhone screen.
PS: If you're starting a new app, I strongly suggest you using the storyboard if your app won't have a lot of views... it's really easy to get started and it lets you see your app flow at a glance.
The ratina display just doubles the resolution of original iPhone. If you don't provide separate graphics for retina display, then system just doubles the resolution of resources.
The points are related to physical size of screen, which is similar in old and new iPhones.
For iPads, the screen size changes. This means that its dimension in points will be different from that of iPhone.
duplicating the xib file and renaming that as filename~ipad.xib is working great for me in ios6.1
I've written an application for the iPad that I'd now like to get working on the iPhone (a universal application).
At the moment it runs in the iPhone simulator, but the UIKit elements are positioned using pixel positions - so a lot of them are offscreen. Additionally my UIImages are too big, and need to be scaled to fit the iPhone. How do I go about doing this?
Thanks in advance.
Some more information:
If I position a UIImageView using UIBuilder, the image displayed takes up the same ratio of the screen if displayed on the iPad or iPhone. Which is what I want, however I need to do it programatically.
If I create a UIImageView programmatically it will take up a much larger ratio of the screen on the iPhone compared to the iPad.
Edit:
My nib is actually empty apart from a OpenGL view. The OpenGL view is scaling fine.
I do create a few UIKit controls programmatically and this is where the problem is happening.
Probably the easiest way: make two separate xibs (1 for iPad, 1 for iPhone).
Start a new universal project and migrate the curent one into it, it'll take some time, but it'll save you a lot of headaches.
I just finish my iPhone game using cocos2d. But before I put it on the AppStore, I'd like to make it work on iPad (which have a bigger screen) and iPhone 4 (which have a bigger resolution).
So, how can I determine programmatically that my app is running on an iPhone, iPad or iPhone 4, to be able to use the correct coordinates / images in my game?
Thanks for your help!
Between iPad and iPhone — Already answered many times.
Between iPhone and iPhone 4 — The size reported is still 320×480, so you don't need to change anything about the coordinates. Create an #2x alternative for the images if you need a high resolution UI image.