コード例 #1
0
ファイル: HelloWorldScene.cpp プロジェクト: ReeLiu/Numic
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;
}
コード例 #2
0
ファイル: GameScreen.cpp プロジェクト: 4an70m/FallingBlocks
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;
}
コード例 #3
0
ファイル: GameCommonScene.cpp プロジェクト: yjq13/PrisonBreak
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;
}
コード例 #4
0
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;
}
コード例 #5
0
ファイル: SceneGameMain.cpp プロジェクト: linml/FlyBirdCC3
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;
}
コード例 #6
0
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;
}
コード例 #7
0
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;
}
コード例 #8
0
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;
}
コード例 #9
0
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;
}
コード例 #10
0
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;
}
コード例 #11
0
ファイル: GameScene.cpp プロジェクト: Gifan/bird
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;
	}
}
コード例 #12
0
ファイル: GameScene.cpp プロジェクト: finleylan/MyFlappyBird
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;
}
コード例 #13
0
ファイル: GameScene.cpp プロジェクト: suli1/suli1-myGame
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;
}