Posts Tagged ‘iphone’

SDK 4.0 Bloated Executable

Wednesday, June 30th, 2010

In more SDK 4.0 learnings, we came across a file size problem with Propaganda Lander in moving to SDK 4. The Unix Executable File became twice as big as it used to be under the 3.0 SDKs. There was no rhyme or reason for this that we could see.

If you are someone who cares about keeping your app’s file size under the 3G download limit, it is important to optimize as best as you can do get it under 20MB. A lot of games really don’t care which will be an annoyance to someone who wants to buy the game but has no WiFi service nearby. Other games just can’t be that small and then there’s nothing you can do about it.

We are pretty adamant about keeping Propaganda Lander under 20MB. Even with all our wondrous musical tunes, movies with voice overs, and pretty graphics we demand to have a game that can be downloaded from anywhere there is a 3G signal. After all, we are making a game for a mobile phone first and a portable music device second.

The reason why the executable file was twice as big under SDK 4 was because it defaults to compiling for iPad as well as iPhone. I see no reason to have both binaries when most games have specific versions for iPhone and iPad. You can fix this by checking Build Active Architecture Only in the project settings.

You should enable Dead Code Stripping as well–it usually is by default. There’s also Optimization Level which defaults to [-Os] for fastest, smallest and tends to be best.

MoviePlayer in iOS 4

Thursday, June 24th, 2010

In the quest to make Propaganda Lander run under iPhone SDK 4.0 and eventually utilize Game Center, I’ve run across some problems/solutions with multitasking. The most recent problem was with MPMoviePlayer. Propaganda Lander plays a movie on each planet plus a nice little video after you’ve beaten the game so movie playing had to work.

SDK 4.0 changes how the MPMoviePlayer works. I think it is now much better than it was before. You have more control over it. It will also, by default, mix with other audio as well. Right now, Propaganda Lander will kill your iPod if a movie plays. We didn’t particularly like that but, there was no choice in the matter. There is now! The iOS 4 version of Propaganda Lander will have this feature.

So, Apple has created an MPMoviePlayerViewController that you can use as a view to control the movie. MPMoviePlayerController still exists but is slightly different. In the past, creating an MPMoviePlayerController would just take over the device and play the movie. You now need to add your MPMoviePlayerController’s view to a UIView or UIWindow.

The MPMoviePlayerViewController will auto rotate if the device’s orientation changes. This was not ideal for Propaganda Lander as it only plays in one orientation: OrientationLandscapeRight. In order to get around that, we had to use the UIView from the MPMoviePlayerController and transform it accordingly.

Here is some code straight out of Propaganda Lander for movie player in iOS 4 :)

You’ll need this for the degrees to radians conversion

#define degreesToRadian(x) (M_PI * (x) / 180.0)

This is the actual code:

MPMoviePlayerController * theMovie;
theMovie = [[MPMoviePlayerController alloc] initWithContentURL: movieURL];
UIView * movieView = [theMovie view];

[movieView setFrame: CGRectMake(0, 0, 480, 320)];

CGAffineTransform landscapeTransform;
landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate(landscapeTransform, 80, 80);

[movieView setTransform: landscapeTransform];
theMovie.scalingMode = MPMovieScalingModeAspectFit;
theMovie.fullscreen = TRUE;
theMovie.controlStyle = MPMovieControlStyleNone;
theMovie.shouldAutoplay = TRUE;

[[[UIApplication sharedApplication] keyWindow] addSubview: movieView];

If you would like to use the MPMoviePlayerViewController that has all the auto rotation features, it would look like this:

MPMoviePlayerViewController * movieView;
movieView = [[MPMoviePlayerViewController alloc] initWithContentURL: movieURL];

MPMoviePlayerController * theMovie = [movieView moviePlayer];
theMovie.scalingMode = MPMovieScalingModeAspectFit;
theMovie.fullscreen = TRUE;
theMovie.controlStyle = MPMovieControlStyleNone;
theMovie.shouldAutoplay = TRUE;

[[[UIApplication sharedApplication] keyWindow] addSubview: movieView.view]

When you the movie is done playing, you will want to remove it. You can do so by using the NSNotificationCenter to get a callback when the movie is done.

[[NSNotificationCenter defaultCenter] addObserver: self
	selector: @selector(movieFinishedCallback:)
	name: MPMoviePlayerPlaybackDidFinishNotification
	object: theMovie];

When the movie is finished, it will call the movieFinishedCallback method which would look something like this:

- (void)movieFinishedCallback: (NSNotification*) notification;
{
	[[NSNotificationCenter defaultCenter] removeObserver: self
		name:MPMoviePlayerPlaybackDidFinishNotification
		object: [notification object]];

	MPMoviePlayerController * theMovie = [notification object];

	[theMovie.view removeFromSuperview];
	[theMovie release];
}

This ONLY works in iOS 4 devices. If you also need to target iPhone OS 3.0 or 2.0, you will need to check for the OS and then have the former MPMoviePlayer code as well. Since Propaganda Lander still targets iPhone OS 3.0, we made this function to check for the OS.

std::string getOS()
{
	UIDevice * device = [UIDevice currentDevice];
	NSString * os = [device systemVersion];

	if([os isEqualToString:@"4.0"])
		return "4.0";
	if([os isEqualToString:@"3.0"])
		return "3.0";
	if([os isEqualToString:@"3.1"])
	        return "3.1";
	if([os isEqualToString:@"3.2"])
		return "3.2";
	if([os isEqualToString:@"3.1.2"])
		return "3.1.2";
	if([os isEqualToString:@"3.1.3"])
		return "3.1.3";

	return "";
}

There’s some C++ and Objective-C in there as you can see. I actually wanted to return numbers but, strings will do for now. You can just as well return NSString’s exclusively if you’d like. As you can also see, we don’t care about OS’s below 3.0. OS 3.2 is the iPad OS and should have no effect for iPhone development but, I left it in there anyway. I believe 3.2 uses the same MPMoviePlayer code as iOS 4.0.

So if your movie player suddenly stops working in iOS 4.0, this is why and this is how to fix it. :)

New Modes for Propaganda Lander!

Monday, June 7th, 2010

Hello friends! Jess here with an update on two new modes for Propaganda Lander: Remix: Survival and Easy Mode.

Remix: Survival is a sensory assault of epic proportions. Players will attempt to survive as long as possible while we throw every nasty enemy known in Rickster’s Universe at them. In order to create this new mode, Tommy has had to re-haul our level editor to offer even more customization. We can now control waves of different enemy types through timing, random amperage ranges and frequency. Therefore, I’ve spent the last couple of days tweaking and testing to create an hyperactive experience. The types of issues I’ve run into mainly deal with offering an experience that has peaks and valleys instead of an experience that amps up only to plateau. What we’ve decided is to offer a sort of three steps forward, one step back mechanic that allows the player to feel like they’ve accomplished a great feat for surviving a particularly hard wave and to facilitate an innate feeling of tension and drama. Also, one other issue I’ve had to deal with is beating Tommy’s high score, but that’s more of a personal policy. The last bits that we have to deal with is optimization for all devices and implementing the soundtrack.

For all you folks that find the Lander to be a little too punishing, we’ve started on an Easy Mode. Easy Mode is exactly what it sounds like, fewer enemies, more power-ups, and less damage make it easier for the casual player to really enjoy Propaganda Lander. I’d have to say that the most difficult part of creating Easy Mode has been striking a balance between making things easier but still retain the challenge. I tend to make levels pretty difficult, look at hardcore mode for example, and it’s been a practice in self-control to really loosen things up a little. We still need to do some testing before we release Easy Mode but I think it’s totally worth it to invite casual gamers into the fold.

Fresh Apps

Monday, May 3rd, 2010

Hello lovelies! Check out our Fresh Apps page and make us the freshest app in all the land!

http://www.freshapps.com/propaganda-lander/

Brand Spanking New Gameplay Footage!

Tuesday, April 13th, 2010

A smattering of level gameplay from Propaganda Lander. Stunts performed by Tommy.