Feeds:
Posts
Comments

Posts Tagged ‘iPhone’

Compression

What’d you do to my phone bill?!

If your game is going to send data over the network, remember that it’s going to cost your users money to do that. If it costs too much – i.e. if they raise an eyebrow even a bit at the cost – you’re in trouble. To avoid this, you’ve got to compress any data sent over the network. The second place where uncompressed data can screw up your app is in the game. Uncompressed text data stored in the game can slow load times and compromise the user’s experience. Large amounts of text data in-game need to be compressed and doing so can speed up your load times, which is always a plus. Copy and add these two files to your project to get around these two landmines:

1. Xcode -> Project -> Edit Project Settings -> Linking -> Other Linker Flags -> -lz (be sure to do it for all configurations)
2. follow the usage in the main.m file below
//
//  Compress.h
//
@interface Compress : NSObject {
}
// Returns a data object containing a Zlib compressed copy of the receivers
// contents.
+ (NSData *)compress:(NSData *)data;
// Returns a data object containing a Zlib decompressed copy of the receivers
// contents.
+ (NSData *)decompress:(NSData *)data;
@end
//
//  Compress.m
//
#import “Compress.h”
#import “zlib.h”
@implementation Compress
// 16K chunks for expansion
const int CHUNK_LENGTH = 16384;
+ (NSData *)compress:(NSData *)data {
if ([data length] == 0) {
return data;
}
z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.total_out = 0;
strm.next_in = (Bytef *)[data bytes];
strm.avail_in = [data length];
// Compresssion Levels:
//   Z_NO_COMPRESSION
//   Z_BEST_SPEED
//   Z_BEST_COMPRESSION
//   Z_DEFAULT_COMPRESSION
if (deflateInit(&strm, Z_DEFAULT_COMPRESSION) != Z_OK) {
return nil;
}
NSMutableData *compressed = [NSMutableData dataWithLength:CHUNK_LENGTH];
do {
if (strm.total_out >= [compressed length]) {
[compressed increaseLengthBy:CHUNK_LENGTH];
}
strm.next_out = [compressed mutableBytes] + strm.total_out;
strm.avail_out = [compressed length] – strm.total_out;
deflate(&strm, Z_FINISH);
} while (strm.avail_out == 0);
deflateEnd(&strm);
[compressed setLength:strm.total_out];
return [NSData dataWithData:compressed];
}
+ (NSData *)decompress:(NSData *)data {
if ([data length] == 0) {
return data;
}
unsigned full_length = [data length];
unsigned half_length = [data length] / 2;
NSMutableData *decompressed = [NSMutableData dataWithLength:full_length + half_length];
BOOL done = NO;
int status;
z_stream strm;
strm.next_in = (Bytef *)[data bytes];
strm.avail_in = [data length];
strm.total_out = 0;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
if (inflateInit(&strm) != Z_OK) {
return nil;
}
while (!done) {
// Make sure we have enough room and reset the lengths.
if (strm.total_out >= [decompressed length]) {
[decompressed increaseLengthBy:half_length];
}
strm.next_out = [decompressed mutableBytes] + strm.total_out;
strm.avail_out = [decompressed length] – strm.total_out;
// Inflate another chunk.
status = inflate(&strm, Z_SYNC_FLUSH);
if (status == Z_STREAM_END) {
done = YES;
} else if (status != Z_OK) {
break;
}
}
if (inflateEnd(&strm) != Z_OK) {
return nil;
}
// Set real length.
if (done) {
[decompressed setLength:strm.total_out];
return [NSData dataWithData:decompressed];
} else {
return nil;
}
}
@end
//
//  main.m
//
#import <Foundation/Foundation.h>
#import “Compress.h”
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *string = @”This is a test of the compression library. Usually text compresses better than binary data. Don’t forget to add ‘-lz’ to ‘Other Linker Flags’ in your project settings!”;
NSData *data = [string dataUsingEncoding:[NSString defaultCStringEncoding]];
NSData *compressedData = [Compress compress:data];
printf(“compressed bytes: %d\n”, [compressedData length]);
NSData *decompressedData = [Compress decompress:compressedData];
printf(“decompressed bytes: %d\n”, [decompressedData length]);
NSString *decompressedString = [[NSString alloc] initWithData:decompressedData encoding:[NSString defaultCStringEncoding]];
NSLog(decompressedString);
[decompressedString release];
[pool release];
return 0;
}

Read Full Post »

First, but not last, Impressions

Your name and icon jive, and people tap through and purchase your app. Good deal. Now you have to make them not regret the decision. Remember that the first impression could be the only impression you get to make, so the first 30 seconds a user spends with your app is critical; one loading screen, or one second of loading, too many, and you’ve lost your user’s attention. To avoid a flame out like this, there are a few things you can do to get them playing as soon as possible and not staring cross-eyed at loading screens.

The big one is loading. If there’s a lot to load, find a way to disguise it; load in the background while the player is progressing through the UI menus. If that’s still not enough, then take the Madden route and show tips, hints, strategy while the game is loading – give your users information they would be interested to read so the loading doesn’t seem so long. You can use the UI menus to your advantage to disguise loading, but don’t create a labyrinth between there and the actual gameplay. Your users want to start playing, so keep the UI menus simple and straight-forward, make the experience crisp and clear, and keep load times to a minimum. Here are a few tips:

1.) To start playing the game just have a button that says “Play” or “Start,” don’t get clever with words like “Engage” or “Lift Off!”
2.) Keep unnecessary options off of the main UI menus; you probably don’t need “Credits” or “About” buttons on the main menu. Has anyone ever clicked on one of those? Also, if the user is starting the game for the first time and your game has multiple levels, don’t force your user to select “Level 1.” Just send them there automatically. They just started playing, of course they have to choose Level 1.
3.) Disable the title bar via Info.plist, not programatically. If you do it programatically, it takes a little longer and it just looks messy when that title bar hangs around a second or two into loading. It’s all in the details.
4.) Don’t disable the user’s music. That’s amateur hour, dudes.
5.) Once the user has played more than once, offer an option to restart the game exactly where they left off so the don’t need to flip through all the UI menus. If you do this, though, also offer an option to disable this feature.

Follow these tips and just keep in mind that you should do everything you can to stay out of your user’s way between the moment they tap to open your app, and begin game play.

Read Full Post »

Naming Your App

The Hook

SimCity, Grand Theft Auto, Command & Conquer. Intriguing, right? In just a word or two, even if you hadn’t heard of these games before, you get some idea about the game; a simulated city, stealing cars, and something having to do with controlling armies. Now take these names; Half-Life, Madden, Halo. Who the hell knows what these games are about based only on the name, without any prior knowledge? Obviously all of the aforementioned titles are among the best selling of all time, but their names serve very different purposes. One set provides some kind of instant information about the game while the second set assumes its customer has a deeper knowledge of the title. Unfortunately for you, smallbore iPhone app developer, you are neither as recognizable as John Madden, nor do you look as bad-ass as Master Chief. So, unless Microsoft Game Studios is publishing your app, you’re going to need to stick with the “SimCity” prototype when it comes to naming your app. All you’ve got to catch your potential customer’s eye is one or two words, and an icon. Here’s how to make the most of them.

Action + Description. That’s the key. Don’t get caught up in names that are too complicated or that depend on your prospective customer’s ability to link the name to some other reference. Say you’ve got a game about blowing up planets in space. For us of the Star Wars ilk, it may be tempting to name this app “Alderon” after Princess Leia’s home-planet which was destroyed by the Death Star in “A New Hope”. Bad instinct. Assume your clientele is not as well versed in the minutiae of Star Wars and instead call your app something like “PlanetBlast” — there’s really only one thing that name could mean. As for this game’s icon, apply the universal rule of thumb: Keep It Simple Stupid. Don’t go with a squadron of one millimeter long spaceships attacking four microscopic planets. One planet with a big explosion coming out the side of it will tell us all we need to know: “PlanetBlast has to do with blowing up planets.” Once you’ve made a name for yourself, you can get a little more risky, but for the moment, all you’re looking for is the jingle that sticks in someone’s head, gets them to tap-through and, hopefully, buy your app.

Good App Names/Icons:

Solitaire – We all know solitaire, and we all know the playing cards’ meaning. Perfect example of Keep It Simple Stupid.

iSniper – A nice play on the iPhone name combined with a recognizable idea, the sniper game. The crosshairs say it all for the icon.

Crazy Penguin Catapult – A catchy and memorable name. Even if you don’t exactly understand how the game consists of catapulting penguins, you don’t really care because you’d like to see that flying penguin on the icon in action.

Flick Fishing – Active words, and intriguing because it suggests movement from the user is required. The icon, a fish going for a hook, is safe and simple.

Bad App Names/Icons:

Blackbeard – Well, we assume it’s pirate related. But is it an action game? An adventure game? Turns out it’s a puzzle game, but who would know? The icon – just a pirate ship – looks fine, but doesn’t give us any further hint about the game.

Oort Storm – This is in the “Alderon” vein… We assume it’s in space because there’s a spaceship on the icon, but that’s all we know. You lost me and I’m on to the next app.

Abigale – Who? What? When? Wh- ahh, who cares. Next app.

Read Full Post »

Get Off My Boat, err, App!

The waters off Somalia isn’t the only place pirates disrupt the work of good, honest folks just trying to get their haul of tuna back to port. The iPhone app store is picked apart daily by the world’s internet pirates and a burgeoning library of apps – some 6,000 of the 25,000 for sale in the app store – are now available online for free. Big Brother (Apple) sits back in his chair – hands up, palms out, to show how clean they are – and spouts some kind of “the enemy of my friend is my friend”-type of head scratcher. So we’re on our own out here in a leaky fishing trawler trying to protect our catch from zooted up pirates and, let me tell you, Obama’s Navy Seal sniper team ain’t nowhere in sight, brother. So all you got is your wiles; here’s how to use ‘em.

First, you’re going to want to know if your app has been hacked. That genetic code of your app – Info.plist – will give you all the evidence you need.

1. If the file, once uploaded, is in text format, you’ve been hacked. When you upload your app, the file is converted into binary code, so if Info.plist is in text, it’s because someone wanted to change the parameters to allow your app to work on any phone and they’ve converted it back to text in order to do that.

2. Search for “SignerIdentity” in your uploaded Info.plist file. This is the fingerprint of a hacker. It’s the Shibboleth for your app to work on any phone. If it’s there, it shouldn’t be there.

3. When you’re finished with your Info.plist file, you know its size. So if that changes once it’s been uploaded, somebody’s gotten into it and screwed around.

Ok, so the pirates have their grappling hooks thrown over the side of your boat and a dude with no teeth and one ear has you looking cross-eyed at the business end of an RPG. It’s time to get diplomatic, so get out your sticks and carrots.

You’ve got a couple options. You can either shut out users who have a pirated app and just make the thing not work. But this is overkill, there’s no need to scuttle the ship right away. Instead, set a time limit, or max number of times a user can open the app, and when one of those parameters is met, display a message and explain that it appears the app on their iPhone is pirated and, please, we’re just family people trying to eke out a living in this cruel, electronic world, so why not click this link and dole out the measly $2.99 for our app? This tactic has been tried, and the results were surprising — conversion rates – from pirate-copy user to legit-copy user – of around 10% were seen when a calm explanation of the situation and an invitation to purchase the app were offered. The added bonus to this approach is that when someone cracks your code, it won’t be immediately obvious to the hacker that there is a built in fail-safe; he/she may play for a few minutes and move on to the next app thinking that this one is cracked. But when the hacked app is downloaded, after a few minutes, or a few uses (whichever you decide) users will get the notification that their copy is pirated and a request to buy the legit version.

There you have it. If only diplomacy worked this well in Somalia.

Read Full Post »

iPhone Audio Basics

Sounds Nice

It’s all in the details. You’re so focused on getting your app just right – making the splatter effect when missile meets buffalo in your “BuffaloZapper 2: The ReZappening” app, perfect – that you forget the system on which your app will be played was not designed with only your app in mind; your user has his or her own things going on with their phone, too, and they don’t want your app to blot those things out.

The big spot where this comes into play is with sound and music. Your exploding buffalo noise might be great, but your users might not care if they can’t have their favorite Anthrax track playing in the background when it happens.

So you’ve got to have your sounds right. To do this, you need to consider the different situations that could arise for a user and what expectations they would have for your app, their iPhone, and their music. Below is a chart that diagrams all the sonic situations your app should be prepared to accommodate for its users.

Headphones Plugged In iPod Music Playing Silent Switch On 

(iPhone only)

Music Sound Effects

Read Full Post »