Scene* HelloWorld::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); // 'layer' is an autorelease object auto layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
void HelloWorld::onEnter() { Layer::onEnter(); addEdge(); }
void HelloWorld::addEdge() { Size visibleSize=Director::getInstance()->getVisibleSize(); auto body=PhysicsBody::createEdgeBox(visibleSize); auto node=Node::create(); node->setPhysicsBody(body); node->setPosition(visibleSize.width/2,visibleSize.height/2); addChild(node); }