本文整理汇总了C++中Boss::addCannon方法的典型用法代码示例。如果您正苦于以下问题:C++ Boss::addCannon方法的具体用法?C++ Boss::addCannon怎么用?C++ Boss::addCannon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boss
的用法示例。
在下文中一共展示了Boss::addCannon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateLevel
Scene* SceneManager::generateLevel(int levelIndex, int score)
{
if (levelIndex == 0) {
Director* director = Director::getInstance();
float height = director->getWinSize().height;
float width = director->getWinSize().width;
// Create start scene
ParallaxBackground* bckMenu = new ParallaxBackground();
bckMenu->addImage("night.png", Vec2(width / 2, height / 1.3), Vec2(0.05, 0));
bckMenu->addImage("city.png", Vec2(width / 2, height / 1.6), Vec2(0.3, 0));
bckMenu->addImage("street.png", Vec2(width / 2, height / 2.6), Vec2(1.0, 0), true);
bckMenu->scheduleUpdate();
auto startScene = IntermediaryScene::create(IntermediaryScene::MENU);
startScene->setBackground(bckMenu);
// Create dummy player
auto dummy = DummyPlayer::create();
dummy->setPosition(Vec2(width / 2, 130));
startScene->setPlayer(dummy);
// Create music
CocosDenshion::SimpleAudioEngine* audioEngine = CocosDenshion::SimpleAudioEngine::getInstance();
audioEngine->playBackgroundMusic("level0.mp3", true);
Label* playButtonLabel = Label::createWithTTF("Play", "font.ttf", 35);
MenuItem* playButton = MenuItemLabel::create(playButtonLabel, [&](Ref* sender){SceneManager::getInstance().fillStack();});
Label* optionsButtonLabel = Label::createWithTTF("Options", "font.ttf", 35);
MenuItem* optionsButton = MenuItemLabel::create(optionsButtonLabel);
Label* exitButtonLabel = Label::createWithTTF("Exit", "font.ttf", 35);
MenuItem* exitButton = MenuItemLabel::create(exitButtonLabel, [&](Ref* sender){Director::getInstance()->end(); });
startScene->addMenuItem(playButton);
startScene->addMenuItem(optionsButton);
startScene->addMenuItem(exitButton);
startScene->createMenu();
return startScene;
}
if (levelIndex == 1) {
Director* director = Director::getInstance();
// Create a new GameLayer
GameLayer* firstLevelLayer = GameLayer::create();
// Create a background
ParallaxBackground* bckFirstLevel = new ParallaxBackground();
float height = director->getWinSize().height;
float width = director->getWinSize().width;
// Create animations and bullets
bckFirstLevel->addImage("night.png", Vec2(width / 2, height / 1.3), Vec2(0.05, 0));
bckFirstLevel->addImage("city.png", Vec2(width / 2, height / 1.6), Vec2(0.3, 0));
bckFirstLevel->addImage("street.png", Vec2(width / 2, height / 2.6), Vec2(1.0, 0),true);
bckFirstLevel->scheduleUpdate();
// Create music
CocosDenshion::SimpleAudioEngine* audioEngine = CocosDenshion::SimpleAudioEngine::getInstance();
audioEngine->playBackgroundMusic("level1.mp3", true);
// Create player
Player* hero = Player::create();
hero->setPosition(Vec2(width / 2, 130));
hero->setTag(PLAYER_TAG);
hero->setScore(score);
// Create boss
Boss* boss = Boss::create(OBJECT_FIRSTBOSS);
BossCannon* cannon1 = BossCannon::create(OBJECT_FIRSTBOSS_CANNON_1, OBJECT_FIRSTBOSS_CANNON_1_D, OBJECT_BOSSBULLET_LASER);
cannon1->setPosition(Vec2(123, 105));
cannon1->setFireMethod(1, 10, 50);
BossCannon* cannon2 = BossCannon::create(OBJECT_FIRSTBOSS_CANNON_2, OBJECT_FIRSTBOSS_CANNON_2_D, OBJECT_BOSSBULLET_SPIKEBALL);
cannon2->setPosition(Vec2(150, 183));
cannon2->setFireMethod(2, 10, 50);
BossCannon* cannon3 = BossCannon::create(OBJECT_FIRSTBOSS_CANNON_3, OBJECT_FIRSTBOSS_CANNON_3_D, OBJECT_BOSSBULLET_BALL);
cannon3->setPosition(Vec2(59, 148));
cannon3->setFireMethod(3, 3, 50);
boss->addCannon(1, cannon2);
boss->addCannon(2, cannon1);
boss->addCannon(3, cannon3);
// Create Interactive object factory
InteractiveObjectFactory* mailboxFactory = InteractiveObjectFactory::create(OBJECT_MAILBOX, director->getWinSize().height * 1.6 / 800, false, MAILBOX_COLLISION_BITMASK, true, false, true);
mailboxFactory->setPositionInterval(Vec2(height / GROUND_PERCENTAGE_FOR_BOX + 10, height / GROUND_PERCENTAGE_FOR_BOX + 10));
mailboxFactory->setSpawnFrequency(5);
mailboxFactory->setSpeed(Vec2(-(Director::getInstance()->getWinSize().width * 10.0 / 800), 0));
InteractiveObjectFactory* rocketFactory = InteractiveObjectFactory::create(OBJECT_ROCKET, director->getWinSize().height * 1.6 / 800, false, ROCKET_COLLISION_BITMASK, true, false, false);
rocketFactory->setPositionInterval(Vec2(100, height));
rocketFactory->setSpeed(Vec2(-(Director::getInstance()->getWinSize().width * 25.0 / 800), 0));
rocketFactory->setSpawnFrequency(20);
//.........这里部分代码省略.........