本文整理汇总了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;
}
示例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);
}
}
}