当前位置: 首页>>代码示例>>C++>>正文


C++ Aircraft::setPosition方法代码示例

本文整理汇总了C++中Aircraft::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Aircraft::setPosition方法的具体用法?C++ Aircraft::setPosition怎么用?C++ Aircraft::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aircraft的用法示例。


在下文中一共展示了Aircraft::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

// on "init" you need to initialize your instance
bool TestAircraft::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}

	// ------------
	// init input manager
	// ---------------
	InputManager* input = InputManager::sharedInstance();
	CCDirector::sharedDirector()->getKeypadDispatcher()->addDelegate(input);

	// -------------
	// init physics
	// -----------
	PhysicsManager::sharedInstance()->enableDebugDraw(true);
	GB2ShapeCache::sharedGB2ShapeCache()->addShapesWithFile("png/physics.plist");

	// step
	schedule(schedule_selector(TestAircraft::stepForPhysicsManager));

	// -----------------
	// Init Audio
	// ------------
	SimpleAudioEngine::sharedEngine()->preloadEffect("wav/exploStd.wav");

	// ------------
	// Hero Aircraft
	// -----------
	Aircraft* hero = Aircraft::createHeroAircraft();
	addChild(hero);

	CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
	hero->setPosition(screenSize.width/2, screenSize.height/2);

	GameController::sharedInstance()->setPlayerAircraft(hero);

	// ------------
	// create menu
	// -------------
	CCMenu* menu = CCMenu::create();

	// straight menu item
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("straight", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// omni 
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("omni", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// ray gun 
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("ray gun", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// tank
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("tank", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// boss00
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("boss00", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// boss01
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("boss01", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	// hero
	{
		CCMenuItemFont* menuItem = CCMenuItemFont::create("hero", this, menu_selector(TestAircraft::menuItemCallback));
		menu->addChild(menuItem);
	}

	menu->alignItemsVertically();
	addChild(menu);

	menu->setPositionX(menu->getPositionX() + 200);



	return true;
}
开发者ID:1194451658,项目名称:chromium-bsu-x,代码行数:95,代码来源:TestAircraft.cpp

示例2: menuItemCallback

void TestAircraft::menuItemCallback(CCObject* menuItem)
{
	CCMenuItemLabel* menuItemLabel = dynamic_cast<CCMenuItemLabel*>(menuItem);

	CCSize screenSize = CCDirector::sharedDirector()->getWinSize();

	if(menuItemLabel)
	{
		CCLabelTTF* label = dynamic_cast<CCLabelTTF*>(menuItemLabel->getLabel());

		if(!label)
			return;

		string labelString = label->getString();

		if(labelString == "straight")
		{
			// straight
			{
				Aircraft* enemy = Aircraft::createEnemyStraight();
				addChild(enemy);
				enemy->setPosition(screenSize.width/2, screenSize.height/2 + 150);
			}
		}
		else if(labelString == "omni")
		{
			// enemy omni
			{
				Aircraft* omni = Aircraft::createEnemyOmni();
				addChild(omni);
				omni->setPosition(screenSize.width/2, screenSize.height/2 + 150);
			}
		}
		else if(labelString == "ray gun")
		{
			// ray gun
			{
				Aircraft* enemy = Aircraft::createEnemyRayGun();
				addChild(enemy);
				enemy->setPosition(screenSize.width/2, screenSize.height/2 + 150);
			}
		}
		else if(labelString == "tank")
		{
			// tank
			{
				Aircraft* enemy = Aircraft::createEnemyTank();
				addChild(enemy);
				enemy->setPosition(screenSize.width/2, screenSize.height/2 + 150);
			}
		}

		else if(labelString == "boss00")
		{

			// enemy boss
			Aircraft* boss = Aircraft::createBoss00();
			addChild(boss);
			boss->setPosition(screenSize.width/2, screenSize.height/2 + 150);
		}

		else if(labelString == "boss01")
		{
			// boss 01
			{
				Aircraft* enemy = Aircraft::createBoss01();
				addChild(enemy);
				enemy->setPosition(screenSize.width/2, screenSize.height/2 + 150);
			}
		}

		else if(labelString == "hero")
		{
			Aircraft* hero = Aircraft::createHeroAircraft();
			addChild(hero);
			hero->setPosition(screenSize.width/2, screenSize.height/2);
			GameController::sharedInstance()->setPlayerAircraft(hero);
		}
	}
}
开发者ID:1194451658,项目名称:chromium-bsu-x,代码行数:80,代码来源:TestAircraft.cpp


注:本文中的Aircraft::setPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。