Hey guys,
I've got exciting news: I've just pushed a beta version of the long awaited Sparrow 2.0 to GitHub! I know that many of you have been waiting for this for a loooong time.
However, let me assure you: it has been worth the wait! Sparrow 2.0 contains lots of great new features, and brings the framework to a whole new level.
BTW, before you go pulling, beware that it's now found in a new GitHub repository:
https://github.com/Gamua/Sparrow-Framework
I'll probably use the old repository for the 1.x development (if that goes on at all), and will do all 2.x work in the new repository.
Next up, a disclaimer: the version doesn't yet contain all the features that are planned; however, I think it's in a good enough state that you guys can have a look and play around with it. Any feedback is welcome!
What's also important is that this version contains many API changes. I fixed the names of some methods (for consistency with other classes and/or Starling), moved some things around, etc. Thus, it won't suffice to update the Sparrow source: you'll have to modify your games as well!
With that out of the way, here are the most important changes:
1) Based on iOS 5.0 and OpenGL ES 2.0
These are now the minimum requirements of Sparrow. That means you'll need at least an iPhone 3GS or an iPad 1 to run a Sparrow 2.0 game.
2) Using ARC and modern Objective-C syntax internally
Sparrow is now completely based on ARC. I must say I really enjoyed working with ARC. If you haven't adopted yet, I can warmly recommend it. 99% of the time, you don't have to think about memory management any more. It just works!
3) Batched Rendering
Sparrow has become much smarter when it comes to the rendering architicture. This means your games will be *much* faster! Here's proof: on my iPhone 4S, the Sparrow benchmark rendered about 1200 objects. Now, it's TWICE this number: 2500 objects!
4) Block-based event listeners
This is something I wanted to have for a long time -- now it's possible! You can add an event listener like this now:
[button addEventListenerWithType:SP_EVENT_TYPE_TRIGGERED block:^(SPEvent *)event
{
NSLog(@"button triggered");
}];
Why didn't I add this sooner, you may ask? Well, previously, this was super-dangerous. Just use "self" or any member variable within the block, and you've got a memory leak. Terrible!
But the latest updates of Xcode help with this: you'll get a warning right away when you do something dangerous in the block. You can still make something stupid, but it's much easier to avoid.
5) More convenience for event dispatching
A small, but convenient change: you can now dispatch simple events (i.e. standard SPEvent objects) with this method:
// previously:
[self dispatchEvent:[SPEvent eventWithType:type]];
// now:
[self dispatchEventWithType:type];
6) Block-based tween callbacks
Tweens no longer dispatch events, but use block-callbacks instead. This is much more convenient to write. Look a this:
tween.onUpdate = ^{ NSLog(@"tween updated"); };
tween.onComplete = ^{ NSLog(@"tween completed"); };
7) Better control over tweens
Tweens now have new properties: "repeatCount", "repeatDelay" and "reverse". They replace the old "SPLoopTypes".
B) Games now extend "SPSprite", not "SPStage"
Since the stage logic was a constant source of confusion, your root object is now a conventional "SPSprite". There's still a stage, but that will be created by Sparrow. Furthermore, you can now access your root object from anywhere via "self.root".
9) Convenient access of stage and juggler
Again, something that was always more painful than necessary. Access those object like this, now:
id stage = Sparrow.stage;
id juggler = Sparrow.juggler;
10) Asynchronous loading of textures - from disk or URL
Now you can *finally* load textures without freezing your user interface. Do it like this:
[SPTexture loadFromFile:@"image.png" onComplete:^(SPTexture *texture, NSError *outError)
{
NSLog(@"Loaded texture");
// texture is now accessible via "texture" block argument.
}];
11) New class "SPViewController"
Remember the nice view controller that was found in the scaffold previously? That's now part of the core. If you look at the scaffold now, you'll see that it's very lightweight -- while offering the same functionality.
12) Skewing
Display objects now have two new properties: "skewX" and "skewY". Use them to, well, skew your objects horizontally or vertically. =)
---
Known issues:
1) Currently, Sparrow 2.0 is rather slow in the iPad 1. This is because the GLKit rendering methods that I use are slower than the old OpenGL ES 1.1 methods. There is something I can (and will) do about this, though.
2) Note that the startup code of Sparrow has changed completely. If you migrate an existing project to the new version, I recommend you start with the new scaffold and import your code into it.
3) The "SPCompiledSprite" is gone. At a later time, it will come back via "[sprite flatten]". But that requires the same changes as the iPad 1 problems I mentioned above.
4) What's still missing: a "blendMode" property on display objects, and a "SPStatsDisplay" that shows the current frame rate and number of draw calls. Other than that, this version is rather feature complete.
So, anybody, please give it a try! I'm looking forward to your comments. =)