Hi,
i just wanted to try the joints with physics world,
so i created two physics body and tried the PhysicsJointFixed class.
but when I run it,the app crashes.what’s wrong with it?
here’s the code:
circle = Sprite::create("cir.png"); circle->setPosition(winSize.width/2 , winSize.height/2); auto circleBody = PhysicsBody::createCircle(circle->getContentSize().width/2 , PhysicsMaterial(0,0,0)); circle->setPhysicsBody(circleBody);
enemy = Sprite::create("cir.png"); enemy->setPosition(winSize.width/2, winSize.height/2); auto enemyBody = PhysicsBody::createCircle(enemy->getContentSize().width/2 , PhysicsMaterial(0,0,0)); enemy->setPhysicsBody(enemyBody);
PhysicsJointFixed* joint = PhysicsJointFixed::construct(circle->getPhysicsBody(),enemy->getPhysicsBody() ,Vec2(winSize.width/2 , winSize.height/2 )); this->getScene()->getPhysicsWorld()->addJoint(joint); addChild(enemy); addChild(circle);