1.创建有个有物理特性的场景
auto s = Sence::createWithPhysics();
s->getPhysicsWorld()->setGravity(Vec2(0,-50));
auto l = Layer::create();
s->addChild(l);
2.设置物理世界的边界
auto edge = Node::create();
setContentSize(Size());
setPhysicsBody(PyhsicsBody::createEdgeBox(Size()));
edge->setPosition(Point());
auto sp = Sprite::create();
sp->setContentSize(Size());
SetPyhsicsBody(PhysicsBody::createBox(Size()));
原文链接:https://www.f2er.com/cocos2dx/344891.html