I'm creating a static shape in chipmunk (using SpaceManager) and attaching a cpCCSprite to it.
However, I need the anchor point of the sprite to be off center, but when I change the anchor point of the sprite, the shape & sprite no longer align.
So if I change the anchor point like this
[sprite setAnchorPoint:ccp(0.5, 0.3)];
The sprite is drawn accordingly, but I expected the shape to "move" with it. Here's a picture of what I mean.
how the cannon should look http://www.tomelders.com/bin/cannon.png
On the left is the shape and the sprite aligned properly. I've not changed the anchor point.
On the right is the sprite with an anchor point of ccp(0.5, 0.3)
I am also rehashing the static shape every frame.
Here's how it's created
// create the sensor
sensor = [spaceMgr addRectAt:pPoint mass:STATIC_MASS width:53 height:81 rotation:0];
sensor->sensor = YES;
sensor->collision_type = 2;
//Create the sprite
CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:@"bownce-sprites-comic-sized.png"];
barrel = [[cpCCSprite node] initWithShape:sensor texture:texture rect:CGRectMake(3, 428, 53, 82)];
[self addChild:barrel];
// set the ancor point
[barrel setAnchorPoint:ccp(0.5, 0.3)];
[barrel setPosition:pPoint];