About Cocos2dx C++ physicsbody

About Cocos2dx C++ physicsbody
0

I’m in trouble. There is a problem when the flipper rebounds the ball. When the flipper is raised, the ball will sink into the flipper. Please tell me how to resolve.

// ball material setting
ballBody = MyBodyParser::getInstance()->bodyFormJson(ballSpr, “ball”, PhysicsMaterial(0.2f, 0.0f, 0.0f));

if (ballBody != nullptr)
{
    ballBody->setMass(10.0);
    ballBody->setMoment(100.0f);
    ballBody->setDynamic(true);
    ballBody->setRotationEnable(true);
    ballBody->setCategoryBitmask(ball_MASK);
    ballBody->setCollisionBitmask(flipper_MASK);
    ballBody->setContactTestBitmask(true); 
    ballSpr->setPhysicsBody(ballBody);
}

// flipper material setting
flipperBody = MyBodyParser::getInstance()->bodyFormJson(flipperSpr, “flipper”, PhysicsMaterial(1.0f, 0.0f, 0.0f));

if (flipperBody != nullptr)
{
    flipperBody->setMass(90.0);
    flipperBody->setMoment(10000000.0f);
    flipperBody->setDynamic(true);
    flipperBody->setRotationEnable(true);
    flipperBody->setCategoryBitmask(flipper_MASK);
    flipperBody->setCollisionBitmask(ball_MASK);
    flipperBody->setContactTestBitmask(true); 
    flipperSpr->setPhysicsBody(flipperBody);
}

Try updating physics step manually. Search into docs or forum you will find solution for same.