cocos2d iphone - Joint on the edge of the circle -


  • the green square box2d ground.
  • the bigger circle connected ground revolute joint, , can rotated.
  • all circles b2_dynamicbody

i want joint smaller circles on edge or border of bigger circle shown below. please tell me how can achieve , kind of joint have use? when rotate big circle small circle should stick @ place.

enter image description here

go through code....
// create joint between hook big circle

wheelsprite = [[ccsprite alloc] initwithfile:@"herowheel.png"]; wheelsprite.visible = false; wheelsprite.scale = 1.0*hero_size_factor; wheelsprite.rotation = 0.0; wheelsprite.anchorpoint = cgpointmake(0.5,0.5); [layer addchild:wheelsprite z:5];  ballbodydef.userdata = wheelsprite;  //create hook between big circle   hook = world->createbody(&ballbodydef);  b2polygonshape hookshape; hookshape.setasbox(0.2,0.1);  b2fixturedef hookdef; hookdef.shape=&hookshape; hookdef.density=0.5f*hero_size_factor; hookdef.friction = 0.0f; hookdef.restitution = 0.0f; hookdef.filter.groupindex=herogroupindex;  hook->createfixture(&hookdef);  //create circle shape fixture  b2circleshape wheel1,wheel2,wheel3,wheel4;  float wheelradius = hero_width/4.0f;  //create fixture above shape b2fixturedef ballshapedef1,ballshapedef2,ballshapedef3,ballshapedef4; wheel1.m_p = b2vec2(wheelradius, wheelradius); wheel1.m_radius = wheelradius; ballshapedef1.shape = &wheel1; ballshapedef1.density = 0.0f; ballshapedef1.friction = 0.0f; ballshapedef1.restitution = 0.0f; ballshapedef1.filter.groupindex=herogroupindex; hook->createfixture(&ballshapedef1);    wheel2.m_radius = wheelradius; wheel2.m_p = b2vec2(-wheelradius, -wheelradius);  ballshapedef2.shape = &wheel2; ballshapedef2.density = 0.0f; ballshapedef2.friction = 0.0f; ballshapedef2.restitution = 0.0f; ballshapedef2.filter.groupindex=herogroupindex; hook->createfixture(&ballshapedef2);  wheel3.m_radius = wheelradius; wheel3.m_p = b2vec2(wheelradius,-wheelradius);  ballshapedef3.shape = &wheel3; ballshapedef3.density = 0.0f; ballshapedef3.friction = 0.0f; ballshapedef3.restitution = 0.0f; ballshapedef3.filter.groupindex=herogroupindex; hook->createfixture(&ballshapedef3);   wheel4.m_radius = wheelradius; wheel4.m_p = b2vec2(-wheelradius,wheelradius);  ballshapedef4.shape = &wheel4; ballshapedef4.density = 0.0f; ballshapedef4.friction = 0.0f; ballshapedef4.restitution = 0.0f; ballshapedef4.filter.groupindex=herogroupindex; hook->createfixture(&ballshapedef4);  //create revolute joints between hook , big circle b2revolutejointdef revolutejointdef; revolutejointdef.bodya = hook; revolutejointdef.bodyb = leg; revolutejointdef.collideconnected = false;  revolutejointdef.localanchora.set(0.0,0.0); revolutejointdef.localanchorb.set(0.0,-(hero_height - 0.1)); revolutejointdef.referenceangle = 0; revolutejointdef.maxmotortorque = 5.0*hero_size_factor;   hero_motor = (b2revolutejoint*)world->createjoint(&revolutejointdef); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -