mirror of https://github.com/axmolengine/axmol.git
Update PhysicsTest.cpp
This commit is contained in:
parent
6865b688d5
commit
85edbe2d28
|
@ -1572,21 +1572,25 @@ void PhysicsPositionRotationTest::onEnter()
|
||||||
anchorNode->addComponent(PhysicsBody::createBox(anchorNode->getContentSize()));
|
anchorNode->addComponent(PhysicsBody::createBox(anchorNode->getContentSize()));
|
||||||
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");
|
||||||
|
@ -1597,6 +1601,8 @@ void PhysicsPositionRotationTest::onEnter()
|
||||||
body->setRotationOffset(45);
|
body->setRotationOffset(45);
|
||||||
body->setTag(DRAG_BODYS_TAG);
|
body->setTag(DRAG_BODYS_TAG);
|
||||||
addChild(offsetPosNode);
|
addChild(offsetPosNode);
|
||||||
|
|
||||||
|
offsetPosNode->getPhysicsBody()->setAngularVelocity(5.0f);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue