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* ChoseLevel::createScene(){ auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto Layer = ChoseLevel::create(scene->getPhysicsWorld()); scene->addChild(Layer); return scene; }
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* PlayScene::createScene() { auto scene = Scene::createWithPhysics(); auto layer = PlayScene::create(); scene->getPhysicsWorld()->setGravity(Vec2(0, 0)); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); 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* PivotJointScene::createScene() { auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Vect(0, -400)); auto layer = PivotJointScene::create(); layer->setPhysicWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* GameWorld::createScene() { auto scene = Scene::createWithPhysics(); //scene->getPhysicsWorld()->setGravity(Vec2(0,-400)); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto layer = GameWorld::create(); //scene->getPhysicsWorld()->setUpdateRate(0.02); scene->getPhysicsWorld()->step(1 / 180.0f); scene->addChild(layer); return scene; }
Scene* GameLayer::createScene() { auto scene = Scene::createWithPhysics(); // scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); auto layer = GameLayer::create(); layer->setPhyWorld(scene->getPhysicsWorld()); scene->addChild(layer); layer->test(); scene->getPhysicsWorld()->setAutoStep(false);//解决穿透 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* HelloWorld::createScene() { auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setGravity(Vec2(0, -50)); //scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setSpeed(3.0); auto layer = HelloWorld::create(); 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* PointQueryScene::createScene() { auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); // 此demo不需要重力,建构一个失重世界 scene->getPhysicsWorld()->setGravity(Point::ZERO); auto layer = PointQueryScene::create(); scene->addChild(layer); layer->setPhysicWorld(scene->getPhysicsWorld()); 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* 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; }
cocos2d::Scene* GameScene::createScene() { srand((unsigned)time(nullptr)); auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setGravity(Vec2(0,0)); GameLogic::PhysicsWorld = scene->getPhysicsWorld(); auto game = GameScene::create(); scene->addChild(game); return scene; }
Scene* HelloWorld::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setGravity(Vec2(0, 0)); auto layer = HelloWorld::create(); layer->SetPhysicsWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
Scene* LevelTwo::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); //scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Vec2(0, -300)); auto layer = LevelTwo::create(); layer->SetPhysicsWorld(scene->getPhysicsWorld()); scene->addChild(layer); return scene; }
//ステージ Scene* MainScene::createSceneWithStage(int level) { // 物理エンジンを有効にしたシーンを作成する auto scene = Scene::createWithPhysics(); // 物理空間を取り出す auto world = scene->getPhysicsWorld(); // 重力を設定する world->setGravity(GRAVITY_ACCELERATION); // スピードを設定する world->setSpeed(12.0f); //MainSceneインスタンスをcreate?レイヤーを作成 //なぜMainScene()なのか auto layer = new MainScene(); //レイヤーインスタンスが存在し、レベルが設定されていれば、autoreleause if (layer && layer->initWithLevel(level)) { layer->autorelease(); } else { CC_SAFE_RELEASE_NULL(layer); } //レイヤーをsceneに追加 scene->addChild(layer); return scene; }
Scene* HelloWorld::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->getPhysicsWorld()->setGravity(Vec2(0, -1000)); // 'layer' is an autorelease object auto layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
Scene* NewGameScene_japan::createScene() { auto NewGameScene_japan = Scene::createWithPhysics(); // 'scene' is an autorelease object Vect gravity(0, -0.5f); NewGameScene_japan->getPhysicsWorld()->setGravity(gravity); //NewGameScene_japan->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); Size visibleSize = Director::getInstance()->getVisibleSize(); auto body = PhysicsBody::createEdgeBox(Size(visibleSize.width, visibleSize.height), PHYSICSBODY_MATERIAL_DEFAULT, 3); auto node = Node::create(); node->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2)); node->setPhysicsBody(body); NewGameScene_japan->addChild(node); // 'layer' is an autorelease object auto layer = NewGameScene_japan::create(); // add layer as a child to scene NewGameScene_japan->addChild(layer); return NewGameScene_japan; }
Scene* GameScene24::createScene() { auto scene = Scene::createWithPhysics(); Vect gravity(0,0); scene->getPhysicsWorld()->setGravity(gravity); //开启测试模式 //scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); //创建一个世界 Size visibleSize = Director::getInstance()->getVisibleSize(); //创建一个空心盒子刚体,作为我们游戏世界的边界(避免游戏内的物体跑出屏幕) //参数分别是刚体大小。材质(其实就是我们一些预设的数据)、边线厚度 auto body = PhysicsBody::createEdgeBox(Size(visibleSize.width,visibleSize.height),PHYSICSBODY_MATERIAL_DEFAULT,3); body->getShape(0)->setFriction(0.0f); body->getShape(0)->setRestitution(1.001f); body->getShape(0)->setDensity(1.0f); //创建一个节点用于承载刚体,这样刚体就能参与到游戏的物理世界 auto node = Node::create(); node->setPosition(visibleSize.width/2,visibleSize.height/2); node->setPhysicsBody(body); scene->addChild(node); auto layer = GameScene24::create(); scene->addChild(layer); return scene; }
Scene* PingPong::createScene() { auto scene = Scene::createWithPhysics(); scene->addChild(PingPong::create()); scene->getPhysicsWorld()->setGravity(Vect(0.0f, 0.0f)); return scene; }
Scene* GamePlaying::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); scene->getPhysicsWorld()->setAutoStep(true); scene->getPhysicsWorld()->setGravity(Vec2(0,-198)); scene->getPhysicsWorld()->setDebugDrawMask(0xff);//デバッグ用 // 'layer' is an autorelease object auto layer = GamePlaying::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
Scene* GameScene::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics( ); scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_NONE); scene->getPhysicsWorld()->setGravity( Vect(0.0f, 0.0f) ); // 'layer' is an autorelease object auto layer = GameScene::create(); layer->SetPhysicsWorld( scene->getPhysicsWorld() ); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
Scene* CredditScene::createScene() { // 'scene' is an autorelease object auto scene = Scene::createWithPhysics(); //scene->getPhysicsWorld() -> setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); // 'layer' is an autorelease object auto layer = CredditScene::create(); // turn gravity on and apply it to the scene scene->getPhysicsWorld() -> setGravity(Vect(0, -98.0f)); layer -> setPhysicsWorld(scene->getPhysicsWorld()); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; }
Scene* Level::createScene(){ auto scene = Scene::createWithPhysics(); auto layer = Level::create(); layer->world = scene->getPhysicsWorld(); layer->world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); scene->addChild(layer); return scene; }
void CoreComponentModel::updateSensors(boost::shared_ptr<Environment>& env) { if (sensor_ != NULL) { dVector3 gravity; dWorldGetGravity(getPhysicsWorld(), gravity); sensor_->update(this->getRootPosition(), this->getRootAttitude(), env->getTimeElapsed(), osg::Vec3(gravity[0], gravity[1], gravity[2])); } }
void PhysicsBody::addToPhysicsWorld() { if (_owner) { auto scene = _owner->getScene(); if (scene) scene->getPhysicsWorld()->addBody(this); } }
void PhysicsBody::removeFromPhysicsWorld() { if (_owner) { auto scene = _owner->getScene(); if (scene) scene->getPhysicsWorld()->removeBody(this); } }