シマリス (SpaceManager を使用) で静的な形状を作成し、それに cpCCSprite をアタッチしています。
ただし、スプライトのアンカー ポイントを中心からずらす必要がありますが、スプライトのアンカー ポイントを変更すると、シェイプとスプライトが整列しなくなります。
このようにアンカーポイントを変更すると
[sprite setAnchorPoint:ccp(0.5, 0.3)];
スプライトはそれに応じて描画されますが、形状が「動く」ことを期待していました。ここに私が意味するものの写真があります。
大砲の外観 http://www.tomelders.com/bin/cannon.png
左側はシェイプとスプライトが適切に配置されています。アンカーポイントを変更していません。
右側はアンカーポイントがccp(0.5, 0.3)
また、フレームごとに静的形状を再ハッシュしています。
作成方法はこちら
// 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];