Is there any PhysicsJointPin alternative in Box2d physics?

Is there any PhysicsJointPin alternative in Box2d physics?
0.0 0

#1

This code only worked with inbuilt physics. But i want to use box2d physics separately .

bool GameScene::onTouchBegan(Touch* touch, Event* event)
{
log("Touch called");
auto location = touch->getLocation();
auto arr = sceneWorld->getShapes(location);

PhysicsBody* body = nullptr;
for (auto& obj : arr)
{
    log("Touch getting");
    
    // if ((obj->getBody()->getTag() & DRAG_BODYS_TAG) != 0)
    {
        body = obj->getBody();
        break;
    }
}

if (body != nullptr)
{
    log("Touch got");
    
    Node* mouse = Node::create();
    auto physicsBody = PhysicsBody::create(PHYSICS_INFINITY, PHYSICS_INFINITY);
    physicsBody->setDynamic(false);
    mouse->addComponent(physicsBody);
    mouse->setPosition(location);
    this->addChild(mouse);
    PhysicsJointPin* joint = PhysicsJointPin::construct(physicsBody, body, location);
    joint->setMaxForce(3000.0f * body->getMass());
    sceneWorld->addJoint(joint);
    _mouses.insert(std::make_pair(touch->getID(), mouse));
    
    return true;
}

return false;
}

void GameScene::onTouchMoved(Touch* touch, Event* event)
{
auto it = _mouses.find(touch->getID());

if (it != _mouses.end())
{
    it->second->setPosition(touch->getLocation());
 }
 }

void GameScene::onTouchEnded(Touch* touch, Event* event)
{

auto it = _mouses.find(touch->getID());

if (it != _mouses.end())
{
    this->removeChild(it->second);
    _mouses.erase(it);
    
    //scheduleOnce(schedule_selector(GameContrler::checkTagetComplete),1);
  }
}

#2

Not sure exactly what you’re after but this link
http://www.iforce2d.net/b2dtut/joints-overview

shows all the joint types in Box2d


#3

I have already gone through these documents but that didn’t suit my current requirement .So,i decided to use inbuilt cocos 2d x physics.

Can you explain me this line.If i removed this then what will happen

 // if ((obj->getBody()->getTag() & DRAG_BODYS_TAG) != 0)