All posts for the month March, 2011

I just submitted a minor update to iDjembe that adds Retina display graphics, a new icon, and a new app info screen. For some bizarre reason it’s selling fairly well, so using it to cross-promote Removr and my upcoming game, Sugar Rush, may help the sales of my other apps.

Speaking of Sugar Rush, the first beta went out yesterday. I’m still waiting for some of the final graphics & sounds. The release is scheduled for Apr. 28.

I’m working on a new game that depends on the accelerometer, which makes testing in the simulator difficult. I asked on Twitter about a hack to use the accelerometer in the simulator and was pointed to iSimulate.

iSimulate is a brilliant application that runs on your iPhone, along with a library that needs to be linked into simulator builds of your application. The iSimulate application connects to your computer over your wireless network and lets you send accelerometer, compass, and multi-touch events to the iSimulate-enabled application running in the simulator.

After you finish developing your app, you can then use iSimulate to record video trailers & demos of your app.

In a new app I’m working on, I created a series of lightweight cocos2d sprite subclasses which simply call the superclass init with some parameters. As soon as I called it I ended up crashing with a weird looking stack trace showing lots of nested calls to init methods.

Screen shot 2011-03-06 at 2.18.44 PM.png

My init methods were pretty simple:

@implementation Gummybear

-(id)init {
    return [super initWithName: @"gummybear.png"];


My superclass’s init method used CCSprite’s initWithSpriteFrameName: method.

- (id)initWithName: (NSString*)name
    self = [super initWithSpriteFrameName:name];
    if (nil != self) {
		// do some more initialization here
    return self;

It ultimately ends up calling initWithTexture:, which is where the problem lies. It turns out initWithTexture: is calling [self init]. Guess which init method was getting called?

-(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect
	NSAssert(texture!=nil, @"Invalid texture for sprite");
	// IMPORTANT: [self init] and not [super init];
	if( (self = [self init]) )
		[self setTexture:texture];
		[self setTextureRect:rect];
	return self;

The fix was to simply change the name of my init method to something else.