Merge pull request #499 from aismann/dev

Update PhysicsTest.cpp  (see the debugdraw bug on the small quader)
This commit is contained in:
halx99 2021-09-08 17:23:42 +08:00 committed by GitHub
commit 8f04c7379c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -1573,21 +1573,25 @@ void PhysicsPositionRotationTest::onEnter()
anchorNode->getPhysicsBody()->setTag(DRAG_BODYS_TAG); anchorNode->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
addChild(anchorNode); addChild(anchorNode);
anchorNode->getPhysicsBody()->setAngularVelocity(-5.0f);
//parent test //parent test
auto parent = Sprite::create("Images/YellowSquare.png"); auto parent = Sprite::create("Images/YellowSquare.png");
parent->setPosition(200, 100); parent->setPosition(300, 100);
parent->setScale(0.25); parent->setScale(0.5);
parent->addComponent(PhysicsBody::createBox(parent->getContentSize())); parent->addComponent(PhysicsBody::createBox(parent->getContentSize()));
parent->getPhysicsBody()->setTag(DRAG_BODYS_TAG); parent->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
addChild(parent); addChild(parent);
auto leftBall = Sprite::create("Images/ball.png"); auto leftBall = Sprite::create("Images/YellowSquare.png");
leftBall->setPosition(-30, 0); leftBall->setPosition(-50, 0);
leftBall->Node::setScale(2); leftBall->Node::setScale(0.5);
leftBall->addComponent(PhysicsBody::createCircle(leftBall->getContentSize().width/2)); leftBall->addComponent(PhysicsBody::createBox(leftBall->getContentSize()));
leftBall->getPhysicsBody()->setTag(DRAG_BODYS_TAG); leftBall->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
parent->addChild(leftBall); parent->addChild(leftBall);
parent->getPhysicsBody()->setAngularVelocity(5.0f);
// offset position rotation test // offset position rotation test
auto offsetPosNode = Sprite::create("Images/YellowSquare.png"); auto offsetPosNode = Sprite::create("Images/YellowSquare.png");
offsetPosNode->setPosition(100, 200); offsetPosNode->setPosition(100, 200);
@ -1598,6 +1602,8 @@ void PhysicsPositionRotationTest::onEnter()
body->setTag(DRAG_BODYS_TAG); body->setTag(DRAG_BODYS_TAG);
addChild(offsetPosNode); addChild(offsetPosNode);
offsetPosNode->getPhysicsBody()->setAngularVelocity(5.0f);
return; return;
} }