Scene* MainScene::createScene() { auto scene = Scene::createWithPhysics(); auto world = scene->getPhysicsWorld(); world->setGravity(GRAVITY_ACCELERATION); #if COCOS2D_DEBUG > 0 world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); #endif world->setSpeed(6.0); auto layer = MainScene::create(); scene->addChild(layer); return scene; }
Scene* BreakoutMainScene::createScene() { auto scene = Scene::createWithPhysics(); // Dinh nghia 1 khong gian vat ly auto world = scene->getPhysicsWorld(); world->setGravity(Vect(0.0f , 0.0f)); // Hien thi boder debug world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto layer = BreakoutMainScene::create(); scene->addChild(layer); return scene; }
Scene* GameLayer::createScene() { auto scene = Scene::createWithPhysics(); auto world = scene->getPhysicsWorld(); // No need for gravity. world->setGravity(Vect::ZERO); #ifndef NDEBUG // Display physics in debug mode. world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); #endif // Create layer. auto layer = GameLayer::create(); layer->setPhysicsWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }