Sparrow - a new Open Source iPhone 2D game framework
Hi folks!
Since about early spring 2009 we have been developing a 2D game framework for the iPhone. It is currently in a quite stable and complete state and we plan to make it public (and Open Source -- probably LGPL) soon.
We would really like to get some feedback on the framework before going public. As this forum has often been a place to find useful information when we were stuck, we thought this would be the right place to announce the framework and get some constructive feedback. We would love to give anyone who is interested access to a read-only subversion repository.
But first let me introduce you to "Sparrow".
We had three main goals with the framework:
It had to be
easy to learn
clean & lightweight
fast
It is written in pure Objective-C, so that a developer will have to use only one programming language (no mixing of C++ and Objective-C) and will have easy access to each and every native iPhone library.
But the killer feature of Sparrow is the following:
Many of you will already be familiar with it.
How come? It's very similar to the Flash API. Anyone who has made a Flash game will feel at home instantly. You have got all the classes you are familiar with: DisplayObject, Sprite, TextField, etc. You can use the same event model, including bubbling events, etc. We only made some minor changes where we thought it made sense to do so. (E.g.: instead of the class couple "Bitmap" and "BitmapData", you have got "Image" and "Texture").
Since everything is rendered with OpenGL, you have the best of both worlds: a clean API and fast rendering. And if you want to, you can even plug in your own OpenGL code (e.g. by just writing a custom "render" method of your DisplayObject).
The framework has been developed in parallel with two games that are nearing their completion, as well. So it was already tested in a real life environment.
As we want to keep everything under control, I do not want to post the link to the repository here (yet). I ask anyone who is interested to send a mail to the following address:
office (at) sparrow-framework dot org
Unfortunately, there is not much documentation yet. But there is a well documented demo application included that showcases how to use the library. And, as I said, anyone familiar with the ActionScript API will know what he's looking at.
For anyone who read this far: We are really eager to hear your feedback! We are just a small team who were not happy with the existing libraries out there and thought it made sense to create something that's really well suited for other small teams who are, like us, working on 2D games. Something that allows them to concentrate on their game, not on OpenGL rendering or learning lots of new APIs.
Thanks for anyone who is giving it a try =)
And thanks to the rest of the forum for helping us during the development of the framework, by countless entries in this giant knowledge base we could dig through. =)
Daniel Sperl
Last edited by TheRedge; 10-28-2009 at 11:50 AM.
Reason: forgot to add that it's Open Source ;-)
Create a simple textfield using one of the iPhone's standard fonts:
Code:
SPTextField *textField = [SPTextField textFieldWithWidth:300 height:60
text:@"TextFields can have a border and a color."];
textField.fontName = @"Georgia-Bold";
textField.fontSize = 18;
textField.color = 0xaaaaff;
textField.hAlign = SPHAlignCenter;
textField.vAlign = SPVAlignCenter;
[self addChild:textField];
Now use a textfield with a custom bitmap font:
Code:
// e.g. during startup; file contains coordinates of chars and image filename
[SPTextField registerBitmapFontFromFile:@"mouse.fnt"];
// then, anywhere else:
SPTextField *bmpFontTF = [SPTextField textFieldWithWidth:300 height:120
text:@"It is very easy to use them with Bitmap fonts, as well!"];
bmpFontTF.fontName = @"mouse"; // the font name as set in the .fnt-file
// done!
I hope this code looks as simple and logical for you as it does for us =)
For those who get a weird error like this when trying to compile the Demo project:
Quote:
Argument list too long: recursive header expansion failed at /Some/Path/that/has/nothing/to/do/with/Sparrow.
The demo project uses a cross project references to link to Sparrow. Those are a bit complicated to set up in XCode, and can create this weird error.
The simple solution: Remove the project reference to Sparrow from the Demo project, and add "libsparrow.a" manually after building the Sparrow project. (Just build it in all configurations and then look for "libsparrow.a" via Spotlight). To add the library, ctrl-click on the project name in XCode (top left) and select "Add -> existing files".
The complicated solution:
1. Set up a shared build output directory that will be shared by all Xcode projects.
In the Xcode preferences, tab: "Building", set "Place Build Projects in" to "Customized location" and specify a common build directory.
Set “Place Intermediate Build Files in” to “With build products.”
2. Add a “Source Tree” variable that Xcode can use to dynamically find the static library project.
In the Xcode preferences, tab: "Source Trees", create a new Source Tree variable.
For Sparrow, use SPARROW_SRC and let it point to /some_valid_path/sparrow/sparrow/src/
Thanks to Timothy P. for pointing us at this problem!
Daniel
For those who get a weird error like this when trying to compile the Demo project:
The demo project uses a cross project references to link to Sparrow. Those are a bit complicated to set up in XCode, and can create this weird error.
The simple solution: Remove the project reference to Sparrow from the Demo project, and add "libsparrow.a" manually after building the Sparrow project. (Just build it in all configurations and then look for "libsparrow.a" via Spotlight). To add the library, ctrl-click on the project name in XCode (top left) and select "Add -> existing files".
The complicated solution:
1. Set up a shared build output directory that will be shared by all Xcode projects.
In the Xcode preferences, tab: "Building", set "Place Build Projects in" to "Customized location" and specify a common build directory.
Set “Place Intermediate Build Files in” to “With build products.”
2. Add a “Source Tree” variable that Xcode can use to dynamically find the static library project.
In the Xcode preferences, tab: "Source Trees", create a new Source Tree variable.
For Sparrow, use SPARROW_SRC and let it point to /some_valid_path/sparrow/sparrow/src/
Thanks to Timothy P. for pointing us at this problem!
Daniel
I found that just setting the SPARROW_SRC (step 2 above) allows the demo to build.
Another code sample showcasing the animation system:
Code:
// we want to animate the jupiter-image that was created above
SPTween *tween = [SPTween tweenWithTarget:jupiter time:5.0f transition:SP_TRANSITION_EASE_IN];
// you can animate any property as long as it's numeric (float, double, int).
// it is animated from it's current value to a target value.
[tween animateProperty:@"x" targetValue:310];
[tween animateProperty:@"scaleY" targetValue:0.5];
[tween animateProperty:@"rotation" targetValue:PI_HALF];
// the so-called "juggler" will carry out the tween for you.
[self.stage.juggler addObject:tween];
It seems that somehow your Demo project lost the link to the Sparrow library.
Please have a look if Sparrow is still in the "Direct Dependencies" list of the project. (In the left pane, get the info for the Demo-Project in the Targets-section (!), then look into the "General" tab). If it's not there, try to add it (or just get the project from svn again).
It seems that somehow your Demo project lost the link to the Sparrow library.
Please have a look if Sparrow is still in the "Direct Dependencies" list of the project. (In the left pane, get the info for the Demo-Project in the Targets-section (!), then look into the "General" tab). If it's not there, try to add it (or just get the project from svn again).
I hope this helps!
Daniel
I think I know what happened here. The first thing that I did was to load up the demo and try to compile it. It failed because it wasn't linked into the library. So it created a library but it wasn't usable and thus killed the link to the actual library. This time, I had already setup SPARROW_SRC and it worked the first try.
It's still lacking proper documentation, but we are busy on that part right now. Nevertheless, the demo application should give anyone a good idea about how everything works.
And if you just want to have a look at what can be done with the framework:
the first Sparrow-powered game has just gone online:
This is amazing! I've never used OpenGL, but with this I don't need to! I love how simple it is to create images and manipulate them.
This is a great framework, and I recommend it to anyone making a 2D game. I can't wait till you finish the documentation though.
Although the demo has most features, it doesn't have some that you need for making a game, specifically sound (which your website says should be ready in a few weeks).
For those who have used both, how would you contrast Sparrow with cocos2d? I'm just getting started on an App where it makes sense to use a game framework, and cocos2d seems to be fairly well documented, with quite a number of successfully deployed Apps already in the store, and an active support community.
This is amazing! I've never used OpenGL, but with this I don't need to! I love how simple it is to create images and manipulate them.
This is a great framework, and I recommend it to anyone making a 2D game. I can't wait till you finish the documentation though.
Although the demo has most features, it doesn't have some that you need for making a game, specifically sound (which your website says should be ready in a few weeks).
Hi Neo!
Thanks a lot for the compliments!
The current lack of documentation is really a bummer, you are right. But you won't have to wait much longer -- I am currently creating a manual that covers all important concepts. It will be on the homepage within the next days. (I will make a post on this thread when it's ready.)
And as soon as the documentation is up to date, we will finish the sound classes. They are already in use in PenguFlip, but I want to add some more features before publishing them.
I am honest with you -- Sparrow is indeed a very young framework, so we can't offer a big community for support, and documentation is currently still on its way. Those are definitely 2 arguments against it.
What Sparrow can offer is a very simple API that is (IMHO) easier to learn than that of Cocos2D -- especially if you have worked with Flash / ActionScript 3.
I recommend you just have a look at both frameworks and then decide which suits you more. And perhaps other developers, who have examined both frameworks, can post their opinion here, too?
I took a brief look through the source code for sparrow as I was interested. I noticed two really critical features are missing in my opinion.
1. Nothing appears to be batched, sprites seem to be rotated/scaled using the glrotatef/scale commands and drawn as individual quads.
2. I also noticed no support for 16 bit modes/textures.
Otherwise it looked put together well, and its certainly nice to see another framework out and about in the world.
Thanks for taking the time to analyze it -- I really appreciate that!
The 16 bit mode should be in the next version. Concerning the other point: I am currently evaluating how Sparrow could cache more complex objects to reduce OpenGL calls. (Something like calling [sprite cacheForRendering] or [sprite freeze] that can be used for static geometry, 'compiling' all children into one geometry array.)
For the first public version, the focus was of course on stability and a stable API. Expect more features and enhancements in the future =)
Last edited by TheRedge; 01-25-2010 at 02:04 AM.
Reason: typo
I just wanted to inform you that we added an extensive tutorial to the Sparrow web page (just as promised). It contains all the information you need to get started.
But where is the link to download the project files
No problem, you're welcome!
The zip-File that contains Sparrow contains a folder called "samples". In it, you will find (in "src"-folders) the XCode projects you are looking for. Currently, we just bundled everything into one zip-file.
I just wanted to inform you that the official Sparrow forum has gone online -- so anybody with questions specific to Sparrow can post his questions there, as well.
Hey guys, just telling you that Sparrow 0.8 was recently released. New features include sound support, a MovieClip class, several new transitions, as well as many more features.
Sparrow does not contain physics-code (currently). But you can, of course, combine Sparrow with Chipmunk or Box2D. Especially Chipmunk should be easy to use, since it's a pure C library, and there is even an Objective C wrapper available.
Daniel
Last edited by TheRedge; 06-13-2010 at 05:18 AM.
Reason: add information
For those who have used both, how would you contrast Sparrow with cocos2d? I'm just getting started on an App where it makes sense to use a game framework, and cocos2d seems to be fairly well documented, with quite a number of successfully deployed Apps already in the store, and an active support community.
What would motivate me to use Sparrow instead?
-t
I think "Easy to learn" is the factor that motivates me to use Sparrow.