Tutorial failing at addObject(target)

So I’m doing the tutorial to get a grasp on the engine for the iPhone, but when I finally got to the collision part, the game keeps crashing.

It will crash on both the iterator CCMutableArrayIterator.begin(); and if I comment out the update, it will crash on the CCMutableArray.addobject function. It seems to not like the arrays or something?

Anyone able to help me out?

Note: I have followed the tutorial, and the only difference is that I’ve made an if statement a switch statement in the spriteMoveFinished() function.

I can add cpp in here if needed.

hello, if you paste your code here, it will be helpful.

and what is the engine version you are using?

I am using cocos2d-1.0.0-x-0.9.0.

I’ve attached both the .h and .cpp of the HelloWorld scene.

it crashed because the pointers projectiles andtargets are still null, they ought to be newed in init().

i think you haven’t read the tutorial carefully, there are codes as follows in the tutorial:

// cpp with cocos2d-x

// in init()
// Initialize arrays
_targets = new CCMutableArray;
_projectiles = new CCMutableArray; 

Ohhh! Wow. Yeah, it was like the first few lines of code. I clearly didn’t notice it. Would have figured it would be above where the scheduler for the update() would be in the tutorial instead.

Thanks though! Brain fart.