看来我的角色似乎使用CCAnimation和Cocoa2d 3.x进行了动画设置。问题是当我将我的CCAnimatedSprite设置为physicsBody时,就像我以前的CCSprite一样,我崩溃了

Aborting due to Chipmunk error: Body's moment is NaN.
    Failed condition: body->i == body->i && body->i_inv == body->i_inv
    Source:/Users/Jason/Desktop/RPGGame/RPG/Libraries/Chipmunk/chipmunk/src/cpBody.c:114

但是,如果我删除此行:
mainChar.physicsBody = [CCPhysicsBody bodyWithRect:(CGRect){CGPointZero, mainChar.contentSize} cornerRadius:0];

崩溃消失了,但是物理方法没有应用到我的CCAnimatedSprite上,如何解决这个问题,为什么这条线会导致它?

用于初始化CCAnimatedSprite的完整代码:
 CCTiledMapObjectGroup *objects0  =    [levelOneMap objectGroupNamed:@"mainChar"];
    NSMutableDictionary *startPoint0 =    [objects0 objectNamed:@"startPosition"];
    int x0 = [[startPoint0 valueForKey:@"x"] intValue];
    int y0 = [[startPoint0 valueForKey:@"y"] intValue];
    self.mainChar     = [CCAnimatedSprite animatedSpriteWithPlist:@"AnimateChar.plist"];
    mainChar.position = ccp(x0,y0);
    mainChar.physicsBody = [CCPhysicsBody bodyWithRect:(CGRect){CGPointZero, mainChar.contentSize} cornerRadius:0];
    mainChar.physicsBody.collisionGroup = @"groupPlayer";
    mainChar.physicsBody.collisionType = @"collisionPlayer";
    [mainChar addAnimationwithDelayBetweenFrames:0.1f name:@"AnimateChar"];
    [mainChar setFrame:@"AnimateChar-1.png"];

    [self.physicsWorldNode addChild: mainChar];

最佳答案

只需通过移动

PhysicsBody上方的[mainChar setFrame]行,它工作正常。新秀错误^^

10-05 23:28