Search code examples
ioscocos2d-iphonechipmunk

Cocos2d: Disable rotation display for CCSprite


I am creating a sprite like this:

CatSprite *aCat = [CatSprite spriteWithFile:@"Icon-Small.png"];

// add sprite to CCLayer
[self addChild:aCat];
// and then define the body and shape
cpBody *body = cpBodyNew(10.0f, cpMomentForPoly(1000.0f, num, verts, CGPointZero));

body->p = ccp(x, y);
cpSpaceAddBody(space, body);
cpShape* shape = cpPolyShapeNew(body, num, verts, CGPointZero);
shape->e = 0.5f; shape->u = 1.0f;
shape->data = aCat;
cpSpaceAddShape(space, shape);

I am applying physics and constraints to the body in chipmunk space. What I want is to disable the display of the body rotation, in other words when body rotate I want the sprite to stay on 0 degree. Any ideas please?

Thank you


Solution

  • So there is inevitably somewhere that you are copying the rotation of the body to the sprite. Unless you are using the released-days-ago alpha preview of Cocos2D v3, CCSprites and cpBodies don't actually work together unless you write code that syncs the sprite with the body. Simply don't copy the rotation for that sprite.