Wednesday, January 12, 2011

Carters Coin Flip 1.9

We are working through CCF 1.9 trying to get it off our to-do list. The biggest change will be the inclusion of REALLY HIGH RES photos for the Retina displays. We are also trying to figure out the best way to make this a Universal (iPhone/iPad) application.

As we play with the high res photos we are ashamed of the crappy quality that our current customers are enduring. These new images are really neat. You can really see the detail in the coins if you have an iPhone 4. Also, because we can display so much more, we are moving around the backgrounds a little bit. So, the iPhone 4 gets a slightly different view of home plate or the turf than an older iPhone.

The iPhone 4 is pretty smart in how it deals with images. When you load an image like this:

[UIImage imageNamed:[NSString stringWithFormat:@"%@_heads.png",self.coinName]]

You only reference the lo-res version of your image. Then when any device (like an iPhone 4) that can handle the higher resolution sees that code it goes looking for a file that is the same name but has a slight variation. So, in our example above, it looks for something that has "_heads@2x.png" in its name. This way we don't have to code around what image to display and what resolution etc. When the iPhone 4 doesn't find a high res version of the image, it simply doubles the size of the old image. This is why images can look jagged on the iPhone 4. They are blown up to 2x size.

In an app like CCF, we are always bumping up against size limits because the image files are so big. So, to save space we are taking advantage of this runtime trick of the iPhone 4. Each flipping coin animation is made up of four images: heads, tails, heads at an angle, tails at an angle. The two 'at-an-angle' photos are to make up the illusion that the coin is really rotating. So, giving users a jagged image for those two isn't a problem since they aren't the focus of the animation and since they are only visible for .03 seconds.

When CCF ships later this month it will contain six images for each coin: two for the heads, two for the tails and one each for the at-an-angle view. All together this is about 800K of images per coin. If we had included high res versions of the at-an-angle views that would have added another 4ooK per coin. When the animation happens, the iPhone will pick and choose which graphics it should display and all will be well. We hope you like it.

No comments:

Post a Comment