How can i Joint these two(Car and Wheel)as a single Physics body in a cocos2d-x 3.3? how to add this Joint body into Physics world??
Sprite *car=Sprite::create("abc.png");
car->setPosition(100,400);
car->setScale(1.5, 1.5);
this->addChild(car);
PhysicsBody *car_body=PhysicsBody::create();
car->setPhysicsBody(car_body);
car_body->setGravityEnable(false);
Sprite *wheel=Sprite::create("abc.png");
wheel->setPosition(40,350);
this->addChild(wheel);
PhysicsBody *wheel_bd=PhysicsBody::create();
wheel_bd=PhysicsBody::createCircle(69.0/64.0);
wheel->setPhysicsBody(wheel_bd);
wheel_bd->setGravityEnable(false);
PhysicsJoint *co =PhysicsJointGroove::construct(wheel->getPhysicsBody(),
car->getPhysicsBody(),Vec2(80,250),Vec2(160,250),Vec2(1.0,1.0));
scene->getPhysicsWorld()->addJoint(co); //this line creating error into my code.
I Suspect this Error is Due to your car_body Not having any Shape, Try adding a Shape to ur car_body, DO Something like this Edit:-
In above code your car Physics Body will have a Bounding Box of your Sprite Also u are a little waste full here:-
u should do something like this:-