I'm new to ChipMunk - I'm trying to make this Rose move in space - but I'm missing something but can't figure out the problem.
Code: Select all
CCSprite *rose = [CCSprite spriteWithFile:@"rose.png"];
[rose setPosition:CGPointMake(100, 200)];
[self addChild:rose z:-1];
cpVect roseVerts[]={
cpv(-rose.contentSize.width/2, -rose.contentSize.height/2),
cpv(-rose.contentSize.width/2, rose.contentSize.height/2),
cpv(rose.contentSize.width/2, rose.contentSize.height/2),
cpv(rose.contentSize.width/2, -rose.contentSize.height/2)};
cpFloat mass = 100; //5;
cpBody *roseBody = cpBodyNew(mass, INFINITY);//cpBodyNew(mass, cpMomentForPoly(mass, 4, roseVerts, cpvzero));
roseBody->p = cpv(100,200);
cpSpaceAddBody(_space, roseBody);
cpShape *shape =cpPolyShapeNew(roseBody, 4, roseVerts, cpvzero);
shape->e=0.3;
shape->u=1.0;
shape->data=rose;
cpSpaceAddShape(_space, shape);
Maybe guide me to a great resource.