Category Archives: Mac

A short (and round) history of the button

Early MacOS OK and Cancel buttons
Early MacOS OK and Cancel buttons
The push button. It’s truly the blunt instrument of UI design. While most other controls provide some indication of the type of operation they’re performing – sliders are adjusting a value, a switch is moving between two states – buttons just mean “do something”. What? The only way to tell is to press it and see. But this shouldn’t be the case.
Continue reading A short (and round) history of the button

An iOS Lava Lamp using OpenGL ES shaders

Screenshot of the finished lava lamp effect
Catchy title, eh? This little experiment came about as I’ve been working on an iOS app where I decided to use an embedded OpenGL view, via GLKit, for a bit more flexibility than a plain-old UIView. This found me falling head-first down a rabbit-hole of OpenGL ES shaders. I ended up putting together a little demo that emulates a lava lamp using a nifty bit of GLSL code.
Continue reading An iOS Lava Lamp using OpenGL ES shaders

Drawing animated shapes and text in Core Animation layers

Star and text
Star and text
The other day I was overcome by the desire to create an animated start-burst, price-tag type graphic with iOS. Time to break out some Core Graphics and Core Animation code. On the way to getting it going, I came across some interesting gotchas, which I thought it’d be useful to talk about here.
Continue reading Drawing animated shapes and text in Core Animation layers

Creating an iPad flip-clock with Core Animation

flipclock_oneAs part of the sliding puzzle game I’m developing for the iPhone and iPad (well, I can’t survive on the profits from BattleFingers forever), I looked for a way to represent a numeric score and time display in an interesting way. One of the nicer visual effects you could use for this is the “flip-card clock” style, where each number consists of a top and bottom part, and the top part flips down to reveal the next number. It’s been used in a few other places including the home screen in the HTC Diamond device, and its physical, realistic style fits well with the iPad, so I set about creating a version for the iPhone and iPad using the built-in Core Animation library. Read on for more details.
Continue reading Creating an iPad flip-clock with Core Animation

BattleFingers is here!

BattleFingers text

Well, I’ve done it: I’ve got my first game live on the AppStore. It’s been an interesting journey. I’m terribly bad at getting my hands on devkits and SDKs, having a play with them and then not doing anything constructive. This dates way back to things like the Playstation NetYaroze, which was pretty expensive, and with which I failed to produce anything concrete. So this time around all the pieces were in place: shiny new “gaming” kit, interesting SDK, low cost of entry. I was determined to create!

I’ll be making a series of posts on the process and details of creating it, in the interest of sharing the fun. In the meantime, you can find out more about the game here.

Sound formats for iPhone development

Ahh, back to work today. It’s pretty tough getting back into the swing of things after what turned out to be a long break this year. While I was off I finally got to spend some time working on an iPhone game. After getting hold of the SDK a while back, it’s only now that I’ve gotten around to doing something with it.

One of the things that seemed a little odd about the SDK is it’s use of CAF-format audio files, detailed here. I got hold of a few very nice audio samples from the freesound site, but needed to convert them from WAVs to CAFs.

I thought ffmpeg might be up to the job, but the version I had didn’t list it as an avaliable output format using ffmpeg -formats. However after a bit of digging I discovered that it is supported by libsndfile, so set about installing it using MacPorts:

sudo port install libsndfile

Then I used the included libsndfile-convert app to convert my file:

libsndfile-convert file.wav file.caf

The output format is inferred from the file extension, so you don’t have to specify it. However, when I rebuilt and ran my iPhone app using the new file, it didn’t play back. I suspected there may be something wrong with the format of the file, so I took a look to see what file reported. For the original WAV file I got

file.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 44100 Hz

Unfortunately file doesn’t work on .CAF files, but you can open them using QuickTime Player, and using the Movie Inspector window you can see that the file has the following format:

16-bit Integer (Big Endian), Mono, 44.100 kHz

So it looks like the problem may be libsndfile-convert changing the endian-ness of the file contents, from the x86-style little-endian to Motorola-ish (i.e. pre-x86 Mac) big-endian, which is a bit of a pain. According to the docs, the libsndfile API supports endian-ness manipulation, so it’s probably just the case that the helper app is doing the wrong thing automatically. I’ll look at putting together a small command line app to use the API directly and enable me to batch process .WAV files correctly.

Back to Mac

Well, I’ve finally got round to getting my hands on a Mac – a shiny 17″ MacBook Pro, no less – after last being heavily involved in Mac development about a decade ago when it was all about the somewhat basic IDE (at least in today’s terms) MPW – the Macintosh Programmer’s Workshop. Check it out if you’re doing any retro Mac OS 7 coding, and aren’t scared of an environment without intellisense! It was a blessed relief when MetroWerks came along with CodeWarrior and bought Mac development out of the dark ages. Gutted; I’ve just discovered that they actually discontinued it in July 2005. Still, having just run up Xcode, I can safely say it’s living on in spirit.

More by luck than judgment I picked up the machine a couple of days after the launch of Leopard, so got that included, and it’s a good job because one of the killer features for me was bootcamp, and this comes as standard with the new OS. Don’t worry, I won’t be going into excruciating detail about the other new features – but mostly because I haven’t used previous versions of the OS enough to be able to make a worthwhile comparison.

Despite that, I still think that it’s a stark reminder of how good an OS can be; a solid foundation combined with a good consistent and cutting edge UI experience.

But I’m off to boot back into Windows for a quick bit of HL2 EP2