Scene* HelloWorld::createScene() { //// 'scene' is an autorelease object //auto scene = Scene::create(); // //// 'layer' is an autorelease object //auto layer = HelloWorld::create(); //// add layer as a child to scene //scene->addChild(layer); //// return the scene //return scene; auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto layer = HelloWorld::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* GameScreen::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Point(0,-1000)); //edge Node Size visibleSize = Director::getInstance()->getVisibleSize(); auto body = PhysicsBody::createEdgeBox(Size(visibleSize.width, visibleSize.height * 1.5f), PHYSICSBODY_MATERIAL_DEFAULT,10); auto edgeNode = Node::create(); edgeNode->setPosition(Point(visibleSize.width/2,visibleSize.height/4 * 3)); edgeNode->setPhysicsBody(body); scene->addChild(edgeNode); // 'layer' is an autorelease object auto layer = GameScreen::create(); layer->setPhyWorld(scene->getPhysicsWorld()); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
Scene* Game :: createScene(){ auto scene=Scene::createWithPhysics(); //scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto layer=Game::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* Game1::createScene() { auto scene = Scene::createWithPhysics(); Vect gravity(0.0f, 0.0f); scene->getPhysicsWorld()->setGravity(gravity); auto layer = Game1::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene *SceneGameMain::createscene() { auto pScene = Scene::createWithPhysics(); pScene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);; auto pLayer=SceneGameMain::create(); pLayer->setPhyWorld(pScene->getPhysicsWorld()); pScene->getPhysicsWorld()->setGravity(Vect(0,-1000)); pScene->addChild(pLayer); return pScene; }
Scene* SimplePlatformerScene::createScene() { auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Vect(0, -200)); auto layer = SimplePlatformerScene::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* FruitCutNinjaScene::createScene() { auto scene = Scene::createWithPhysics(); //scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Point(0, -1)); //scene->getPhysicsWorld()->set auto layer = FruitCutNinjaScene::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* HitMeScene::createScene() { auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Point::ZERO); auto layer = HitMeScene::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* LevelFifteen::createScene() { // 创建基于物理引擎的场景 auto scene = Scene::createWithPhysics(); /* scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);*/ scene->getPhysicsWorld()->setAutoStep(false); auto layer = LevelFifteen::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* PhysicalsScene::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); // 创建物理场景 //scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); //开启调试测试 // 'layer' is an autorelease object auto layer = PhysicalsScene::create(); // add layer as a child to scene scene->addChild(layer); layer->setPhyWorld(scene->getPhysicsWorld()); // return the scene return scene; }
bool GameScene::init() { if(Scene::initWithPhysics()) { // this->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); this->getPhysicsWorld()->setGravity(Vect(0, -900)); // Add the background auto backgroundLayer = BackgroundLayer::create(); if(backgroundLayer) { this->addChild(backgroundLayer); } auto statusLayer = StatusLayer::create(); // Add the main game layer auto gameLayer = GameLayer::create(); if(gameLayer) { gameLayer->setPhyWorld(this->getPhysicsWorld()); gameLayer->setDelegator(statusLayer); this->addChild(gameLayer); } // Add the game status layer to show the score and game status if(statusLayer) { this->addChild(statusLayer); } // Add operation layer to control the game auto optionLayer = OptionLayer::create(); if(optionLayer) { optionLayer->setDelegator(gameLayer); this->addChild(optionLayer); } return true; } else { return false; } }
bool GameScene::init() { if(Scene::initWithPhysics()) { //this->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); this->getPhysicsWorld()->setGravity(Vect(0,-900)); } //Ìí¼Ó±³¾° auto backgroundLayer=BackgroundLayer::create(); if(backgroundLayer) { this->addChild(backgroundLayer); } auto statusLayer=StatusLayer::create(); //Ìí¼ÓÖ÷ÓÎÏ·²ã auto gameLayer = GameLayer::create(); if(gameLayer) { gameLayer->setPhyWorld(this->getPhysicsWorld()); gameLayer->setDelegator(statusLayer); this->addChild(gameLayer); } //Ìí¼ÓÓÎϷ״̬²ã if(statusLayer) { this->addChild(statusLayer); } //Ìí¼Ó¿ØÖƲã auto optionLayer=OptionLayer::create(); if(optionLayer) { optionLayer->setDelegator(gameLayer); this->addChild(optionLayer); } return true; }
bool GameScene::init() { bool bRet = false; do { CC_BREAK_IF(!Scene::initWithPhysics()); this->getPhysicsWorld()->setGravity(Vect(0, -900)); auto backgroundLayer = BackgroundLayer::create(); if(backgroundLayer) { this->addChild(backgroundLayer); } auto statusLayer = StatusLayer::create(); auto gameLayer = GameLayer::create(); if(gameLayer) { gameLayer->setPhyWorld(this->getPhysicsWorld()); gameLayer->setDelegator(statusLayer); this->addChild(gameLayer); } if(statusLayer) { this->addChild(statusLayer); } auto optionLayer = OptionLayer::create(); if(optionLayer) { optionLayer->setDelegator(gameLayer); this->addChild(optionLayer); } bRet = true; } while (0); return bRet; }