While Cocos2D is compatible with ARC, simply enabling ARC in the project’s Build Setting will throw several hundreds of errors in your face. Cocos2D doesn’t provide ARC-enabled project templates. Thus this tutorial about how to enable ARC in a newly created Cocos2D Xcode Project.

While none of these steps are overly difficult, you’ll notice there’s plenty of steps to perform. Unavoidably, and on the off chance you don’t already know, I’d like to recommend Kobold2D to you if you want to write ARC enabled Cocos2D apps. Because none of the steps below, really zero, zilch, nada, niente, keine are necessary to enable ARC in Kobold2D. That’s because it ships with 15 template projects all of which have ARC enabled out of the box. And Kobold2D 2.0 with cocos2d-iphone 2.0 is just around the corner.

Self-advertisment aside, these steps are tested with cocos2d-iphone v2.0 but should also work with cocos2d-iphone v1.1 - but admittedly I haven’t tested the process with the v1.1 version. If you find anything that’s not quite working with v1.1 please leave a comment. Preferably with the solution, that’ll be awesome!

UPDATE: I released a video version of this tutorial:

Continue reading »

Xcode 4 Debugging Crash-Course

On October 6, 2011, in idevblogaday, by Steffen Itterheim

What do you do if your app doesn’t behave as it should, or even crashes?

Answer A: Post your problem in just about every programming forum.
Answer B: Use the Xcode Debugger to analyze what’s going wrong.

Since most of you already know how to do A I’ll focus on B in this Xcode 4 Debugging Crash-Course. It’s kind of aimed at beginning Xcode developers but that’s just because I hope - against better knowledge - that experienced developers already know that … thing … that debugger stuff. Ya know?

Continue reading »

cocos2d Book, Chapter 4: First Simple Game

On July 17, 2010, in Announcements, book, cocos2d, by Steffen Itterheim

Chapter 4 - First Simple Game

After Chapter 3 covered the fundamentals of the cocos2d game engine, this chapter will put to use what you’ve learned. The simple game is all about droping enemies that you have to avoid via accelerometer controls. Sort of like an inverse Doodle Jump. But it’s not just about the gameplay itself, I want the game to be reasonably complete with a main menu, scene transitions, game over and of course audio.

The chapter will be submitted on Friday, July 23rd.

Do you have any suggestions for the game?

What do you think should be in a first cocos2d game? Let me know!

Summary of working on Chapter 3 - Essentials

When I started the chapter I wasn’t really sure about its focus and progress was a little slow. Eventually it clicked and I found myself ending up having written more pages than needed and still having a great number of things left untold. The key was looking at the cocos2d API reference documentation and remembering what it was like when I was a beginner. Sure, every class, method and property is there but for a beginning cocos2d developer the API reference is just a huge list of names. In other words, if your experience was or is anything like mine was, it’s frustrating to work with the API reference.

I ended up writing about the cocos2d engine design and its scene graph first, the remaining 80% of the chapter explain in detail with lots of code samples how to use those darn CCNode classes. All the important ones are covered: CCNode, CCScene, CCLayer, CCSprite, CCLabel, CCMenu, CCMenuItem* as well as the Director, Transitions and Actions. Besides the code samples and how-to I’ve added numerous caveats, common mistakes, best practices and other nodes which are so very much needed to make any documentation complete.

For example, how Layers are best used for grouping other nodes together and of course how to enable touch and accelerometer input by adding the required functions which aren’t mentioned in the API reference since they are part of the iPhone SDK API. There’s also some weird recommendation floating around not to use too many Layers because they’re slow. I can’t find the source but what I did find was that this is only true if the Layers enable touch or accelerometer input, because that’s what costs a lot of performance. So what you don’t want to have is several layers accepting input, otherwise use as many Layers as you need - which shouldn’t be many anyway. And if you do need multiple Layers accepting input, why not just use one master Layer (possibly using a Targeted Touch handler) which forwards the input events appropriately to the other Layers?

I’m writing a book for Apress:

Learn iPhone and iPad Cocos2D Game Development: The Leading Framework for Building 2D Graphical and Interactive Applications

I guess someone wanted to be very precise and thorough. 😀

I will blog about the book’s progress here and when it’s published I will add additional materials so readers can continue their journey here. Since this journey is just beginning - I’m submitting the first chapter aptly titled “Introduction” tomorrow - and writing a whole 400 pages book is an entirely new experience to me, I want to let you in on the journey.

Help me help you by providing feedback to the book’s content as I’m writing it!

For the coming weeks, I will announce the current book chapter title and a short description and ask you what you’d like to see in this chapter. I will make these posts every Friday starting tomorrow until the book is complete. In this post you could start by telling me what you’d expect from this book or what you’d like to see in it just given its title? I guess your answer will be “a lot” given the title’s elongated nature. :p

I hope you forgive me if content updates to this website will not be as comprehensive over the coming months, in favor of writing the book and coding sample games. Plus I’m cooking up something special on the side, but all in due time.

Oh, by the way, if you happen to know what kind of fruit that is on the cover I’d like to know. I could just ask my editor but I’d like to see if we can figure it out without the help from Apress. It doesn’t really look like a coconut to me, which would have been fitting given the subject. If you have any ideas what fruit it is, let me know! It sure looks exotic and it’s definetely not a banana nor a lemon. So what is it? The first to post the correct answer in a comment, together with a link to Wikipedia or some other website as proof, gets a copy of the book for free when it’s out (or $40 now)!

And now for something completely different …

As a side note, the Xcode project files from the Xcode Tutorial are now available for download here. I used to ask you to join my Newsletter but I don’t feel too good about hooking you up with my Newsletter using the project as a dangling carrot, so joining the Newsletter will now be a completely voluntary thing. I only send newsletters for substantial updates and important news, at most once or twice per month, so that’s the thing you want if you are already struggling with RSS overflow.

Tagged with:  

I made a few additions to the Xcode Tutorial and the cocos2d FAQ which are based on user questions and concerns.

Xcode Project Tutorial: How to integrate Chipmunk SpaceManager

How to update the cocos2d-iphone code in a project created with a cocos2d Project Template? (Theory & Advice)

How to fix common Box2d compile errors? (must compile using C++)

How to fix common Chipmunk compile errors? (does not compile with C++ code)

How to draw an endlessly repeating Parallax Background? (very simple, very effective)


On Searching the Tutorial & FAQs

I’m still trying to get the search function on the Tutorial and FAQ pages fixed. Currently it works for the Xcode Tutorial only but other search result links may simply show an Error. I’ll try to get this fixed as fast as i can and i’m getting very helpful support from the folks at ScreenSteps Live so i’m hopeful.

Please also note that the search box in the navigation panel doesn’t search the FAQ and Tutorials, just the blog and pages.

Tagged with: