No chicken: Sparrow 0.9 is out!

Daniel Sperl on July 31, 2010

Hello everybody! I am happy to announce that Sparrow 0.9 has just cracked its eggshell and found its way to the download section.

Without further ado, I’ll describe the most important changes in the following sections. The detailed change list is, as always, part of the download package.

Beware: Interface Changes

There’s one thing we had to change for performance reasons. If you use the methods “colorOfVertex:” or “texCoordsOfVertex:”, the ID of the vertices has changed.

  • old order: 0 = top left, 1 = top right, 2 = bottom right, 3 = bottom left
  • new order: 0 = top left, 1 = top right, 2 = bottom left, 3 = bottom right

Sorry for that! But I guess that those methods are not used by the majority of Sparrow users, and it should be easy to change those calls. The alternative would have been for Sparrow to change the IDs internally, but I thought it was better to make the change now instead of carrying a workaround in all future versions of Sparrow.

Other things you should be aware of: Sparrow 0.8 requires the iOS SDK in version 4. The “Base SDK” of all projects was changed to “iOS 4.0”. Of course, you can still deploy to older system versions - that’s the “Deployment Target” setting of your project. That’s the approach that is recommended by Apple.

But now to the real enhancements!

Performance improvements

Isn’t that the coolest benefit of using a framework? You upgrade to a new version, and your application just runs smoother and faster. Better than a free lunch! :-)

The changes won’t be visible when you start the benchmark (part of the demo project), though. The biggest changes were made in parts that are not tested by the benchmark, namely:

  • Touch Events
  • Rendering of Bitmap fonts (SPTextField)

The first change is a direct result of the huge number of objects in the higher levels of “Twins”. Touching a cell in those levels led to a visible performance drop. Well, not any more!

The other thing is something I wanted to improve right from the beginning, but never found the time. Now, all glyphs of a text that uses a bitmap font are sent to OpenGL simultaneously, which makes rendering of those texts much faster (3x-4x!).

Support for high resolution screens

It’s now extremely easy to create your game with crisp, sharp textures for the iPhone4. That’s achieved with the same convention as in Apple’s core libraries: just add the suffix “@2x” to the filenames of your textures, and they will be loaded automatically instead of the low resolution textures - only on devices with an HD display, of course. This works with all kinds of images: plain textures, texture atlases, bitmap fonts.

All you have to do is enable the feature by calling “[SPStage setSupportHighResolutions:YES];” at the beginning of your game.

The demo project is now in full HD - just change the device type of the simulator to see it in action. Other than the line above, no changes to the code of the demo were necessary!

Texture atlas generator

When you work with HD textures, it’s a lot of work to create all textures in two resolutions … normally. But Sparrow has got its own texture generator now, which does all the work for you! Create your images in the high resolution, and then let the tool create two texture atlases for you: the high resolution atlas, and a scaled down version. It even supports automatic sharpening!

Here’s a small introduction - a detailed description and installation instructions can be found in the README file (sparrow/util/atlas_generator/README).

# Basic usage: creates "atlas.xml" and "atlas.png" from the 
# provided images
./generate_atlas.rb input/*.png output/atlas.xml  

# The same with some options
./generate_atlas.rb --scale 0.5 --padding 2 --sharpen \
                    --maxsize 2048x2048 *.png atlas.xml

The next blog entry will show you in detail how to use this feature to create your next game in HD.

"Sparrow's new utilities"

Miscellaneous

In brief, some other minor changes:

  • Another utility, the “texture resizer”, can be used to resize those textures that are not part of a texture atlas
  • Support for loading textures and sounds outside of the application bundle
  • SPMovieClip now dispatches “SP_EVENT_TYPE_MOVIE_COMPLETED”
  • SPJuggler’s “delayInvocation”-method now retains its arguments, which makes it easier to use
  • fixed several bugs (thanks to all of the reporters!)

Last words

I’m very happy with the latest version of Sparrow. As you can see, we added a lot of functionality without bloating the interface - most functionality just works behind the scenes. The code base was also cleaned up in several places.

We are also proud to announce that several games have appeared in the app store that are powered by Sparrow! I’m looking forward to presenting them in a separate blog entry.

Now, happy upgrading! If you encounter any problems after the upgrade, don’t hesitate to post them in the forum - we tried our best to test everything, but you never know!