No chicken: Sparrow 0.9 is out!

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.

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!

5 Comments

Twins

In 2009 we decided to develop three iPhone games (namely Find it!, PenguFlip and Twins) with our Austria-based partner Funworld. During the development of our first iPhone game Find it! we saw that there was a need (at this time at least for us) to create a gaming framework that was easy and fast to develop with. Sparrow is the dogfood that came out of it.

While Sparrow and PenguFlip were released at nearly the same time, the third game called “Twins” was waiting in the queue for attention. But now, after several months the release of Twins has come! That is why i thought it would be fun to share some Twins-related info with you.

The Game

Twins was originally released on Funworld’s PHOTO PLAY console and is a fusion between a typical arcade puzzle and a fast-paced action game. While the original release was themed in a very technical style (“Pick a futuristic lock”) we thought it best to put the game into a “Heal an infected patch of body cells” scenario. The rules of the game thou are still the same: Find two equal connectible bacteria aka twins and connect them. Do this as fast as you possibly can.

Twins comes in two editions: Full and Free. Check it out!

Twins Full

Creating The Menu

For Twins we chose a very similar approach as we did for PenguFlip: The game itself is based purely on Sparrow, whereas the main menu (which includes facebook integration, online highscore system, etc. etc.) is based on our house-internal menu system that uses Cocoa. Those lines of code keep us from reinventing the wheel over and over again for each new game and wasting precious time that could have otherwise been invested into improved game-play. After all developers are lazy people, right? ;-)

Twins Menu

Everytime a player starts a round of Twins the menu system seamlessly fades into Sparrow. On each game-over we fade back to the menu system and unload Sparrow and the game code. This is not only pretty straight-forward, but it also helps us to keep track of possible memory leaks. We just need to check memory consumption before and after a game session. If those numbers do not equal, something’s wrong.

Creating The Game Field

Since the game field of Twins consists of hexagons (body cells) which may or may not be infected with twins, it was necessary to separate the twins textures from the background layer as well as the other functional layers such as selection overlays, warnings, beams and such. This allows to easily create some appealing animations.

Twins Game Field

The game field now consists of a maximum of 52 twin cells each containing 4 layers. That is a number of 208 Sparrow objects (+1 parent) for the game field alone. What’s not included is all the dashboard stuff that is displayed around the game field such as a progress meter, a score display, hint texts, message boxes, buttons and the background. Sparrow handles these numbers very well.

Also, in the picture you can see how Sparrow bubbles events up the object tree. For example: a touch on one of the stars textures (4th layer) bubbles up into the Game Field. In order to keep Twins code clean it was obvious to register one single touch event handler on the “Game Field” to catch those user touches.

Creating The Textures

As so many real-life stories do, it all begins with a pizza. One day we were sitting in a pizzeria and started drawing possible twins on the check. Behold the divine finesse of those sketches!

Twins First Sketches

After redrawing a selection of these sketches on A4 and scanning them into the digital world of Apple I fired up Inkscape and created vector graphics for the twins. Here are the scans of the redraws:

Twins Second Drawing

These vector graphics then went into the Gimp, got sliced and diced and received some nice coloring and shading. What came out of it are our final game textures:

Twins Final Drawing

Take Away

So that’s basically it – the rest was iterative coding, drawing and testing. I hope you had some fun reading this and gained a little insight into our ways.

Before i let you off the hook, i have a few questions:

  • We are re-using a Cocoa-based menu system for our Sparrow games. What is your approach with Sparrow and a game menu?
  • The way i created those textures may or may not be the best way to do this. How do you create your textures?

I am looking forward to your comments!

5 Comments