OS3.0 compatibility: getting the frame callback right.

The minimum compatiblity target for new apps is OS3.0

First, look at the code sample below

animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 16.0) * animationFrameInterval) target:self selector:@selector(drawView:) userInfo:nil repeats:TRUE];

Yes! This code intends to set the frame rate to 16FPS. I started freaking out when running in the OS3.0 emulator and getting a slow, slow, slow frame rate. I started losing faith in NSTimer, not as accurate as CADisplayLink but… …until I spotted the animationFrameInterval multiplier. I’m targetting 20 FPS now, so my frame interval is 3 (60/3), yielding (in the example above) a frightening 5FPS.

Glitching frames

I’ve been feeling a little moody lately because my renderer started ‘glitching frames’. Pausing briefly and periodically. And I’ve been blaming a bit of code I wrote that gets out of the way every really-too-far-to-render object every once in a while (about every second). OK, this iterates a potentially ‘big’ list (how big is big? actually less than 500 elements at most – doh!).

Turns out I’ve been initializing / restarting an AVAudioPlayer at every blooming footstep. If you want footsteps, use a sound loop, and do it the right way…

Status update

This week-end I cleared my dev tasklist. Today I cleared my artwork list and tomorrow I’m getting the sound release ready. Then I should get busy with last minute testing and routine instrumentation while my promotion material is getting ready.

What’s up with the smileys?

Yes! WordPress converts Objective C into strings of smileys. How cute.