Chipmunk + spaceManager
Hello to all I have searched many forums and cannot seem to find an answer to my question. I know that this forum is not particularly for chipmunk or spaceManager but I figured that I would see if I could get any help. My question is, I am making a simple game were the user tries to throw the football threw the center of the tire. I have created two poly shapes for the top and the bottom of the tire which I am wanting to attach to a single tire sprite. I don't know h开发者_运维百科ow to attach two shapes/body's to one sprite and have it attach to the top and bottom and still be able to move the sprite and use it for collision? If possible some sample code would be of great help! thanks. Here is how I am creating my shapes and sprites:
//UPPER HALF TIRE [smgr addPolyAt:cpv(70,195) mass:STATIC_MASS rotation:0 numPoints:6 points:cpv(2,12), cpv(28,8), cpv(33,0), cpv(36,-10), cpv(-33,-10), cpv(-20,8)];
//LOWER HALF TIRE [smgr addPolyAt:cpv(70,125) mass:STATIC_MASS rotation:0 numPoints:7 points:cpv(34,8), cpv(31,0), cpv(25,-9), cpv(7,-13), cpv(-20,-8), cpv(-30,0), cpv(-35,8)];
//Adding the Tire CCSprite *backTire = [CCSprite spriteWithFile:@"TractorTireBack.png"]; backTire.position = ccp(70,160); [self addChild:backTire z:1];
I know that I can attach one image to a shape like this:
cpShape *shape = [smgr addPolyAt:cpv(70,195) mass:STATIC_MASS rotation:0 numPoints:6 points:cpv(2,12), cpv(28,8), cpv(33,0), cpv(36,-10), cpv(-33,-10), cpv(-20,8)]; [super initWithShape:shape file:@"TractorTireBack.png"];
But how would I go about attaching two shapes to this one image? WIth one of the shapes being at the top and the other at the bottom.
do you want the tire to move? If the answer is no you could just leave the two cpShapes as they are and just add a standard CCSprite and position it in place. Use
[self addChild:[smgr createDebugLayer]];
to make the cpShapes visible.
精彩评论