Iphone cocos2d addChild每秒失败一次

Iphone cocos2d addChild每秒失败一次,iphone,objective-c,Iphone,Objective C,我有一个小游戏,它在编译时运行得很好,但是我每一秒 编译它,它会给我一个错误: -(void) addHeroCar{ CGSize screenSize = [CCDirector sharedDirector].winSize; sprite = [CCBodySprite spriteWithFile:@"carNew.png"]; sprite.world = self; sprite.physicsType = kDynamic; sprite.co

我有一个小游戏,它在编译时运行得很好,但是我每一秒 编译它,它会给我一个错误:

-(void) addHeroCar{

    CGSize screenSize = [CCDirector sharedDirector].winSize;
    sprite = [CCBodySprite spriteWithFile:@"carNew.png"];
   sprite.world = self;
   sprite.physicsType = kDynamic;
   sprite.collisionType = kBoxCollisionType;
   sprite.collidesWithType = kBoxCollisionType | kWallCollisionType;
   sprite.position = ccp(screenSize.width / 2, [sprite boundingBox].size.height / 2);
   sprite.density = 0.7f;
   sprite.friction = 0.3f;
   [sprite addBoxWithName:@"box"];
    [self addChild:sprite z:1 tag:HERO_TAG];
    sprite.fixed = YES;

}
调试器向我显示以下错误:

-(void) addChild: (CCNode*) child z:(int)z tag:(int) aTag
{   
   NSAssert( child != nil, @"Argument must be non-nil");
我正在使用其他开发人员提供的cocos2d+box2d包装器,仅供参考

有什么建议吗

问候,,
米尔扎

每编译一次?不是每秒钟都执行该方法或任何事情?调试器会向您显示什么错误?只需添加一个nslog来检查sprite=nil在调用[self addChild….@samfisher]之前,只需在那里设置一个断点并检查变量