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 Embedded In A Cocoa Touch App

On June 12, 2011, in book, cocos2d, by Steffen Itterheim

I just completed this project for the new book chapter about embedding UIKit views/Cocoa Touch in a Cocos2D application. In that case I embedded the Cocos2D view in the View-based Application template and added some controls to start/stop the cocos2d view and change scenes. Here’s the result:

It also correctly auto-rotates. But I noticed an odd bug with auto-rotation enabled for all orientations: the view is designed in portrait mode. If I start the App on my iPod Touch 4 while holding the device in landscape mode, then rotate back to portrait mode once the app has started and enable the cocos2d view, for some reason this causes my device to reboot! I see a transparent white color drawn over the entire screen before the screen goes black and the Apple logo appears.

If anyone has any idea what might be causing this behavior, please let me know. As far as I debugged it is not the initialization of the EAGLView class itself, a scene is already running or about to be run.

I’m guessing it might have to do with the EAGLView initialization, since I rely on Interface Builder to initialize the view. I simply dragged a View object onto IB and changed the class from UIView to EAGLView. Maybe the EAGLView default settings are not supposed to be used and I do need to create the EAGLView manually?

Tagged with:  

[Solved] weird scene changing bug…

On July 27, 2010, in cocos2d, by Steffen Itterheim

I need help. I’ve run into strange problems with a very simple cocos2d v0.99.4 project created from the cocos2d project template. It’s two scenes with a layer each, much like the regular HelloWorldScene layer. Each scene is simply supposed to replace itself with the other scene, on touch. What happens is that the first scene started with runWithScene is never deallocated after the first scene change. So it stays in memory and keeps receiving the touches, which means a touch is always behaving as if switching from the first to the second scene.

What’s more, if I add the onEnter and onEnterTransitionDidFinish methods to the first scene, without adding any code to them, the first scene/layer doesn’t receive any touch events at all. The second scene doesn’t show this behavior and works fine with these methods implemented.

Maybe I’m just overlooking the very obvious, if you could take a look and let me know if there’s anything I’m doing wrong with this code please let me know! Thank you.

Download the code here: ScenesAndLayers02

Tagged with: