Scheduled for release on November 7th, 2011. Continue reading »
For the second edition of the Learn Cocos2D book I compiled an alphabetically sorted list of tools that developers can use for cocos2d projects. Please let me know if there’s a tool missing from this list or if there’s one that won’t work anymore and hasn’t been updated in months.
The following tools can be used for development with cocos2d:
Bitmap Font Tools
BMFont (Windows)
Fonteditor
Glyph Designer
bmGlyph
Hiero
LabelAtlasCreator
Particle Editing Tools
ParticleCreator
Particle Designer
Physics Editing Tools
Mekanimo
PhysicsBench
PhysicsEditor
VertexHelper
Scene Editing Tools
CocosBuilder
Cocoshop
LevelHelper
Texture Atlas Tools
DarkFunction Editor
SpriteHelper
TexturePacker
Zwoptex
Tilemap Editing Tools
Nate Weiss, author of the commercial iPhone Game Kit, would like you to help build the first community driven RPG game for the iPhone. Read his announcement.
He wrote a game design document for you to wet your appetite and learn what needs to be done. It’s an ambitious project that I believe would be awesome to take part in, especially if you don’t have the time and energy to build a complete game project by yourself, but you still like to take part in fruitful game development activities. What the game needs most is to design levels using the popular Tiled Map Editor, and new artworks for tiles, characters and cutscenes.
You do need to have a copy of the iPhone Game Kit to participate, but currently it’s on sale with 30% off and costs only $69. For that you get the complete source code and assets for the Quexlor action RPG and a 150 page game development eBook. I think his product and ebook are excellent and well worth the money, and I’m currently running two ads for Nate on a voluntary basis. You can learn more about the pros and cons of the iPhone Game Kit from these independent reviews:
Add your link to the Cocos2D Linkvent Calendar
Do you have something to share with the Cocos2D community? I haven’t received enough submissions to fill all the days until Xmas, although I do have enough links to post one each day, I’d rather post a link to your website or blog post.
While helping others solve their cocos2d project issues over the past year it became obvious that many projects have at least one major problem in one of these areas:
- memory management
- resource management
- code structure
Examples
Memory management issues normally range from allocating too much memory, either by loading too many textures up front which are only going to be needed later, or by memory leaks such as scenes not deallocating when switching scenes. Resource management problems range from not adding the right resources to the right target, often resulting in increased App size because resources are added to the bundle but never used by the App. It could also mean loading identical resource files except that they have different filenames (copies?), using up additional memory. Or not tightly packing sprites into Texture Atlases but instead using one Texture Atlas per game object - while this is understandable from a standpoint of logical seperation it does waste opportunities for optimization.
Finally, code structure or lack thereof regularly leads to “everything in one class” code design which is most likely an evolutionary process rather than intentional. It’s not uncommon to see classes with thousands of lines of code, sometimes even going past 10,000 lines of code in one class. Other things are using too many CCLayers without them adding a clear benefit, for example just to group all nodes at a specific z order together or to group them by functionality, eg one layer for enemies, one for players, one for background, one for UI, one for score, one for particle effects, and so on - without any of these layers being used for what they’re really good at: modifying multiple nodes at once, like moving, scaling, rotating or z-reordering them. And of course there’s the copy & paste hell, large blocks of code reproduced in various places only to modify some parameters instead of creating a method which takes the modifiable parameters as arguments. Even professionals I worked with got so used to doing that it became hard just to overcome the resistance of letting go of old habits. But they learned.
Summary
Nothing of this code design and structuring strikes me as odd or surprising. I’ve written code like this myself. I also believe if it’s good enough and works, then why the hell not? It’s a matter of experience and it’s only with experience that you clearly see how to improve things. This boils down to the regular learning curve where only training and tutoring and just simply making mistakes and learning from them helps in the long run. That’s how we learn things.
On the other hand, the things like Memory and Resource Management can also be learned but they have a different nature. They can be statistically assessed, they could be calculated and verified automatically. This makes me wonder if there isn’t some kind of automation and information tools that would help developers achieve better results in terms of memory usage and resource management? In the meantime it’s all about raising awareness …
Raising Memory Awareness
Most importantly I think we need to raise more awareness to these issues to cocos2d developers. One step towards that would be for cocos2d to display a “available memory counter” alongside the FPS counter. I used to patch CCDirector to simply display memory instead of FPS since that was always more important to me. Fellow cocos2d developer Joseph sent me his version to display both - I simply didn’t think of the obvious. So if you’d like to see FPS and available memory next to each other I think you can handle the changes to CCDirector outlined here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
// CCDirector.h, add below @interface: +(double) getAvailableBytes; +(double) getAvailableKiloBytes; +(double) getAvailableMegaBytes; // CCDirector.m, add as appropriate: #include <sys/sysctl.h> #import <mach/mach.h> #import <mach/mach_host.h> [...] +(double) getAvailableBytes { vm_statistics_data_t vmStats; mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT; kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount); if (kernReturn != KERN_SUCCESS) { return NSNotFound; } return (vm_page_size * vmStats.free_count); } +(double) getAvailableKiloBytes { return [CCDirector getAvailableBytes] / 1024.0; } +(double) getAvailableMegaBytes { return [CCDirector getAvailableKiloBytes] / 1024.0; } [...] -(void) showFPS { frames++; accumDt += dt; if ( accumDt > CC_DIRECTOR_FPS_INTERVAL) { frameRate = frames/accumDt; frames = 0; accumDt = 0; // the only change in showFPS is this line: NSString *str = [[NSString alloc] initWithFormat:@"%.1f %.1f", frameRate, [CCDirector getAvailableMegaBytes]]; [FPSLabel setString:str]; [str release]; } } |
Raising awareness to leaking Scenes
In addition I highly, strongly and with utmost reinforcement (without pulling out a gun) recommend to cocos2d developers to frequently check your scene’s dealloc methods. Preferably add a breakpoint there, or at the very least add the logging line: CCLOG(@”dealloc: %@”, self). If you want a more visible but less intrusive method you could do something like flashing the screen or playing a sound whenever the last scene is deallocated, so that you get so used to it that when you’re not seeing or hearing it anymore it immediately raises your attention.
If at any time during the development of your project the dealloc method of a scene isn’t called when you change scenes, you’re leaking memory. Leaking the whole scene is a memory leak of the worst kind. You want to catch that early while you can still retrace your steps that might have caused the problem. Once you get to using hundreds of assets and thousands of lines of code and then realize the scene isn’t deallocated, you’ll be in for a fun ride trying to figure out where that’s coming from. In that case, removing nodes by uncommenting them until you can close in on the culprit is probably the best strategy, next to using Instruments (which I haven’t found too helpful in those cases).
I ran into such a problem once because I was passing the CCScene object to subclasses so that they have access to the scene’s methods. The subclass retained the scene and was itself derived from CCNode and added to the CCScene as child. The problem with that: during cleanup of the scene it correctly removed all child nodes but some of the child nodes still retained the scene. Because of that their dealloc method was never called, and in turn the scene was never deallocated.
I’m pleased to announce that the Line-Drawing Game Starterkit is finally available for sale! It’s a source code project for anyone interested in developing a line-drawing game. The gameplay is modelled after the famous Flight Control game. The Starterkit works with the latest cocos2d v0.99.4 version and will at the very least receive compatibility upgrades for future cocos2d versions.
Hop on over to the product page to check out the feature list, the API documentation and a source code sample. You can also download the Starterkit App for iPhone from iTunes. The iPad Edition is still in approval.
Note: for the reminder of July 2010 you can get the Starterkit at an introductory price for only $179!
Positioning of the Starterkit
I’m sorry that you’ve had to wait one and a half months compared to the initially planned release date of June 1st. I double and triple checked every decision I made and you can see some of the results on the Starterkit product page.
I’ve also decided to increase the regular price from the initially intended $199 to $299 effective from August 1st, 2010. One of the reasons being that I initially planned to have multiple licenses including Indie and Commercial ones. I thought long and hard about positioning the Starterkit and eventually decided to sell only Site Licenses. For the individual developer it costs a bit more but for small and commercial teams it’s great news, and small teams and established, dedicated developers is who I am targeting. Those who really appreciate the value of commercial source code saving days and weeks of research and development, and all the trouble, sweat and pain associated with it. And I’m here to help if you have any questions regarding the Starterkit’s source code.
I don’t have plans to make another Starterkit and in all likelihood it will remain the only commercial cocos2d-related product for the remainder of this year.
Book Chapter about Line-Drawing Games
For those who are disappointed about the new price, either grab the Starterkit before August 1st or wait until December for the Learn iPhone and iPad Cocos2D Game Development book I’m writing. It will contain a chapter covering some of the basic aspects of a line-drawing game but without the finer details and complex interactions conveyed in the Starterkit. It’ll be Chapter 12 so in about 8 weeks (Mid-September) I’ll mention it in my weekly book chapter posts.
Closed Sales Period, Summary of
And here’s for transparency: exactly 10 days ago I informed the 668 subscribers of my Newsletter of the closed sales period. The password-protected Starterkit product page received just over 200 unique visitors. During the last 10 days I made 9 sales amounting to about $1,530 with Plimus’ 5% fee already deducted but obviously before tax. All sales were made within the first 4 days after I sent the Newsletter and for the last 6 days sales were absolutely zero. Although I’ve been in contact with several interested parties who didn’t want to or simply couldn’t buy it right now for various reasons. If you’re one of them: you’ll get it for $179 no matter when you make the purchase, just contact me beforehand.
Right now I’m curious to see how sales will be now that the Starterkit is publicly available.
Starterkit Promotion
I’d appreciate if you would tweet and re-tweet this post and mention the Starterkit to all fellow cocos2d-sians! If you would even go so far as writing a serious and honest review on your blog, please get in touch with me.
Just don’t test the waters by mentioning the Starterkit in the cocos2d community forum.
Stance Lance
I wish Ricardo had taken the time to be considerate and then talked to me instead of running off making an assumptive, excessive, and for the most part irrelevant (off-topic) stance post which only served to cause a big commotion among his community while allowing his forum rule “Treat people with respect.” to become a farce.
In Conclusion
In hindsight I’m glad that the whole thing got me thinking in so many new directions. Most importantly it got me in contact with a lot of developers who consciously don’t post on the cocos2d forum. To get those encouraging words and positive feedback and gaining interesting insights from other developer’s perspectives - especially those who tag along silently - really helped me understand the cocos2d development community better. Thank you, you know who you are!
The whole shebang also served as a great motivational factor to pour my everything into the cocos2d book, which came at just the right time to let off steam in just the right way. I’m writing it to be the cocos2d documentation it deserves and the one I always wished it had. I can’t even begin to describe how satisfying it feels to write this book. So much in fact that it hurts to stop writing every time I reach the 27 pages each chapter is expected to have.
Line-Drawing Game Starterkit
Site License! Unlimited Apps!Royalty Free! No Attribution!60 day money-back guarantee!Made with the popular cocos2d-iphone game engine.Compatible with cocos2d-iphone v1.1 and v2.0, Xcode 4.6 and iOS 6.Includes ARC enabled versions of the starterkit! |
All Starterkit project artwork provided by Arezou Ipakchi Design. Promotional images created by Justin from CartoonSmart.
What it is:
Get a head-start for your Line-Drawing game and save days if not weeks of your time! You’ll get gameplay code modelled after the extremely popular Flight Control game. You’ll learn how to draw lines, detect touches on objects, have objects follow a path - and much, much more! Written by a professional game developer and game industry veteran (me) the source code is annotated with lots of comments explaining my rationale and written with readability in mind.
Contains separate iPhone & iPad targets!
The Starterkit includes targets for iPhone and iPad using the same code if you don’t want to create a Universal app, for example to reduce your app’s size or to be able to charge more for the iPad version. If the iPad Target is selected hi-res iPad images will be used. Image selection is done automatically by loading those images whose filenames have the “-ipad” suffix, the same suffix cocos2d uses.
What others are saying:
“Code is quite clearly written and decently documented […] definitely a fine investment.”
From: Commercial cocos2d Code review from Alex Curylo.
“It was an awesome moment when I found the source for a line draw game of this caliber.”
-Franklin Lyons, SpinFall
“Especially the path and movement system is saving me lots of headaches.”
-Martin Hoffmann
Games made with this Starterkit:
Launch Control
![]() |
![]() |
![]() |
Ferries HD
Feature List:
- cleanly seperated and well-structured GameScene code design with a minimum of dependencies
- easy to add new objects and extend object parameters
- touch object & draw a path for it (whether it’s already following a path or not)
- path drawing ends when path is drawn over appropriate target location (eg airstrip for airplanes, respecting angle of approach)
- path drawing ends when arbitrary point limit is exceeded (to avoid slowdowns)
- path is drawn when dragged with thick transparent line style like Harbor Master, without glitches
- path is split into equal length pieces no matter how quickly user moves finger
- objects spawn outside screen, locations can be re-defined and extended
- objects display incoming warning marker at screen border
- objects display collision warning when any two of them are getting too close
- objects follow path to end - then fade out and increase score or continue moving
- objects always rotate in movement direction
- objects bounce back at screen borders
- motivational Labels for successful landings, precached
- Score and HighScore Labels
- HighScore saved to disk between play sessions
- supports both Landscape orientations with autorotation
- loads correct resource files depending on Target (iPhone or iPad)
- proper Pause handling for incoming calls, SMS
- many generally useful Math Helper functions included
- lots of comments explaining rationale and giving tips for improvement
- assertive coding style to help catch coding errors early on
- offline and online documentation
- you can choose between using cocos2d-iphone v1.1 and v2.0
- you can choose between using ARC or classic manual reference counting
- compatible with iOS 5.0 and newer, including iOS 6
- compatible with Xcode 4.6 (the most recent versions also work)
- easy setup: just unzip, open Xcode project, select build scheme, build and run
Questions? Need Help?
Just send me an email.
Legal Disclaimer
Cocos2D is a registered trademark of Ricardo Quesada. Steffen Itterheim, the Learn & Master Cocos2D website and the Line-Drawing Game Starterkit are neither affiliated with nor endorsed by Zynga or Ricardo Quesada.
Try Before Buy!
Buy Now!Site License! Unlimited Apps!Royalty Free! No Attribution!60 day money-back guarantee!Made with the popular cocos2d-iphone game engine.Compatible with cocos2d-iphone v1.1 and v2.0, Xcode 4.6 and iOS 6.Includes ARC enabled versions of the starterkit! |
License Agreement
Copyright
Purchase grants you the License to use and modify the source code and assets under the following Terms and Conditions:
You are not allowed to make the source code publicly available. You are not allowed to give or sell the source code to others, modified or not. Licenses are not transferable.
All Licenses are royalty free. You can make as many free or commercial Apps using the source code as you want. You may re-use any existing assets in your App.
If you do contract work and have or want to give the Starterkit source code to your client, your client needs to purchase a Site License as well.
Site License
Each purchase grants you a Site License. The Site license grants you the use of the Starterkit without restrictions at one site.
A site is an office, building or living space rented or owned by the company or individual making the purchase. It allows anyone working on site to use and modify the Starterkit source code.
Large companies operating at several sites need to purchase a site license for each individual location if the Starterkit is to be used at multiple locations. Contact me if you’re such a corporation and you prefer a flat fee license with your own license text to go along with it.
Support
Updates to the Starterkit are done on an as needed basis. I will also keep it up to date and running with the latest stable releases of cocos2d. Updates are distributed via a download link sent to the email address you used for your order. If your email address ever changes please contact me, ideally you should forward me your order confirmation in that case to speed up the change.
Source Code not covered by this License
The licensed Source Code project contains files which are available for free and are governed by different licenses. The Terms & Conditions outlined here do not apply to source code files which do not contain the Copyright notice “Copyright (year) Steffen Itterheim. All rights reserved.”.
Disclaimer
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Questions? Contact me!
If you have any questions or if you require specific License texts before making a purchase, please contact me.