How do I cater for all iOS platforms using cocos2d - iphone

I want to use Cocos2D framework, but I want to know how to place an object once in code, and for it to appear in the correct position on all devices.

He want's to know how to make universal code for his game.
E.g. Place something dead center for all formats.
Cocos2d automatically fixes positioning for iPhone4.
It uses POINTS not PIXELS to place objects onto the screen, this is your first problem fixed.
For iPad, you need to do some work. I suggest reading this post.
http://michaelgilkes.info/cocos2d-using-hd-images-for-ipad-in-a-universal-app/
I found it helpful and a very good stepping stone to come to a conclusion that allowed me to create a universal application with very little additional code.

I honestly have no idea what you're asking, but possibly you want to know the screen sizes. Here they are in pixels:
iPhone < 4: 320 x 480
iPhone >= 4: 640 x 960
iPad: 768 x 1024

Related

How to make app compatiable for iphone 4S and 5?

I am new to UI design, however a client wants an app ready for both iPhone 4s & 5.
I understand the iPhone 5 will create two bars if the image is not long enough. Many people said coding it at #2x will solve the problem. But I'm not sure exactly what that means.
Do I need to design two versions? What happens if I design only for iPhone 5? Will iPhone 4S users see a squished screen?
Thanks.
First, in a couple of months you'll have to support the iPhone 5's screen size. Apple have announced that it'll be a requirement soon.
Adding a Default.png of the right size is enough to enable an app to support the new screen size but is likely not enough. You'll also need to make sure that all your views resize to fill the screen. There's the old "springs and struts" method and the newer "constraints." There are tutorials you can search for -- Stackoverflow is not a good place for that kind of thing. You'll also need to update any images.
In short, try it in the Simulator and see what happens.
Using #2x is referring to whether or not the image asset is being displayed on a 'retina' screen. For example, if you had a 50x50 pixel image, the 'retina' (#2x) version would be 100x100. This is because 1pt (point) is equal to 2px (pixel) on a retina screen.
There are a variety of ways you can determine is it is an iPhone5 or iPhone4.
In the viewDidLoad, you could check the self.view.frame.size.height to determine which background image to load based on the height of the screen. This would require you to have two different versions of the assets (not including #2x versions), i.e. bg_iphone5.png & bg_iphone4.png.
There are other ways to accomplish this, and people have explained it better than I have here - search StackOverflow and you will surely find what you're looking for.
What happens if I design only for iPhone 5? Will iPhone 4S users see a squished screen?
Don't do this. Design for both.

Creating an app for the iPhone (including iPhone 5) that plays videos

We're about to build an app that plays a bunch of videos on the iPhone.
But we're wondering what the best practice is going to be given the new iPhone 5 screen.
We are going to have to output the videos at either 960 x 640 (traditional iPhone display) or 1136 x 640 (iPhone 5).
Either way we're going to have black bars horizontally or vertically.
We'll have around 300MB of videos.
Any suggestions on how we best tackle this problem?
I would suggest encoding for the larger size and letting those with the smaller display deal with the black bars. Why? Because it is a guarantee that iPhones < iPhone 5 will decrease over time and that iPhones >= iPhone 5 will increase. If you are going to have black bars either way (encoding twice and choosing which one based on hardware is an option, though it might be impractical) you might as well plan for the future.

Max Image Width and Height in Xcode?

I could have sworn that I seen a while back that the max image size you can load into Xcode was 1024 x 1024, meaning you can't use images that are larger than this, but I can't remember where I seen it and I was hoping someone could verify or refute this statement for me? Anyone have any idea? I was hoping to be able to use images that are larger than this incase I need to create an animation file that is very large, but I want to know if this will work first before I start making them. Thanks for any help you can provide.
The UIView docs say:
In iOS 2.x, the maximum size of a
UIView object is 1024 x 1024 points.
In iOS 3.0 and later, views are no
longer restricted to this maximum size
but are still limited by the amount of
memory they consume. It is in your
best interests to keep view sizes as
small as possible. Regardless of which
version of iOS is running, you should
consider tiling any content that is
significantly larger than the
dimensions of the screen.
It don't think XCode has any restrictions on the size of an image.
I've used, large images that 1024x1024 in both iOS and Mac apps. In iOS i've used the large images for maps.
On the Mac App I had them a background for the window.
It's not XCode that have a size limit but the iPhone. The documentation says 1024x1024 like Jason and rckoenes said but as far as I had tested the largest size of a UIView on the iPhone is 16.000 Pixel (not Points! means on retina 8.000.).
Every view you want to make larger must use a UIScrollView or CATiledLayer

What's the changes between developing for the iPhone and the iPhone 4?

Hey, I'm working on an iPhone app but I've heard from some people that it's a size difference between the iPhone and the iPhone 4 and if it's not iPhone 4 committable to use the retain display it will be rejected by Apple.
So my questions is: What size does my app need to be in since it's not 320 x 480 anymore.
And will the app automatically shrink the size down when it's used on an older iPhone or do I have to do something more with it?
Hope this makes sense to you guys!
Thank you in Advance
It's actually a UI design question. Luckily Apple has made it quit easy for developers to upgrade their apps for iPhone 4's retina display. All you need to do is follow a specific naming convention.
To all your UI files in your project (yes, those PNG files), you should make a new set of copies of all of them, doubling heights and widths (e.g. 320 x 480 => 640 x 960), and rename them in the following way:
myFirstImage.png =>
myFirstImage#2x.png
And that's all, hope it helps.
Edited: there is one exception. The icon files and the artwork file. It is slightly more complicated. You should download the iTunes_Connect_Developer_Guide and take a look at related sections.

Can the full 326 ppi of iOS 4 be used for openGL?

While testing my openGL ES app on the new iPhone 4, it seemed as if the openGL wasn't using all 326 ppi, rather the 163 ppi found on the 3G, because of noticeable pixelation. I realize there are 4 times more pixels to calculate, but shouldn't the A4 chip compensate for this?
I'm sure there is a way to take advantage of the stunning resolution, as I have seen in apps on the iTunes Store, but how?
Yes, its quite easy too actually. By default the OpenGL view uses the old scale mode as to not break existing applications because it is a pixel based API rather than a point based API.
To fix this, set the contentsScale of your CAEAGLLayer to 2.0 and bask in the glory.
Not so familiar with the CAEAGLLayer, what is the syntax to set the contentScale to 2.0?