mirror of https://github.com/axmolengine/axmol.git
Update PhysicsTest.cpp
This commit is contained in:
parent
6865b688d5
commit
85edbe2d28
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue