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


C++ Enemy::Activate方法代码示例

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


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

示例1: SpawnBoss

void EnemySpawner:: SpawnBoss()
{
	Enemy* lEnemy;
	lEnemy = dynamic_cast<Enemy*>(_Game->Spawn(new Enemy(), _Game->_Settings->EnemyBossTexture, true, nullptr));
	lEnemy->SetHealth(_Game->_Settings->EnemyBossHealth);
	lEnemy->SetSpeed(_Game->_Settings->EnemyBossSpeed);
	lEnemy->Activate();
	lEnemy->SetText("");
}
开发者ID:h2ogit,项目名称:SFMLtest2-SM2d,代码行数:9,代码来源:EnemySpawner.cpp

示例2: GenerateEnemy

    void EnemyGenerator::GenerateEnemy()
    {
        Enemy* enemy;
        
        // Get all the % values for the colors
        vector<float> allColorKeys = KeysInVector(allColorTypeChances);
        float colorTypeChance = randomPourcentageGenerator();
        //Get a random key from the Vector of keys and use it to get it's paired color enum
        Enemy::ColorType color = allColorTypeChances[GetEnumKey(allColorKeys, colorTypeChance)];

        // Create proper enemy depending on color
        switch (color)
        {
            case Enemy::green:
                enemy = GreenEnemy::Create();
                break;
            case Enemy::orange:
                enemy = OrangeEnemy::Create();
                break;
            case Enemy::red:
                enemy = RedEnemy::Create();
                break;
            default:
                break;
        }
        enemy->color = color;
        
        // Same concept for color but with the shape
        vector<float> allShapeKeys = KeysInVector(allShapeTypeChances);
        float shapeTypeChance = randomPourcentageGenerator();
        enemy->shape = allShapeTypeChances[GetEnumKey(allShapeKeys, shapeTypeChance)];
        
        enemy->enemySprite = Sprite::create(textBank->enemyTexture);
        enemy->enemySprite->setTag(ENEMY_TAG);
        // Used for referencing object to delete
        enemy->enemySprite->setUserData(enemy);
        // Find the proper rect on the enemy spritesheat
        enemy->SetupEnemySpriteRect(enemy);
        // Apply proper collider geometry
        enemy->SetupCollisionShape(enemy);
        // Move above the screen with random X pos
        enemy->SetStartingPos(enemy->enemySprite);
        
        enemyLayer->addChild(enemy->enemySprite);
        
        enemy->Activate();
    }
开发者ID:Jeff0029,项目名称:MobileTest,代码行数:47,代码来源:EnemyGenerator.cpp

示例3: SpawnEnemy

void EnemySpawner:: SpawnEnemy()
{
	Enemy* lEnemy;

	if (Wave == 1)
	{
		lEnemy = dynamic_cast<Enemy*>(_Game->Spawn(new Enemy(), _Game->_Settings->Enemy1Texture, true, nullptr));
		lEnemy->SetHealth(_Game->_Settings->Enemy1Health);
		lEnemy->SetSpeed(_Game->_Settings->Enemy1Speed);
		lEnemy->SetSound(_Game->_Settings->EnemyDeathSound);
	}

	if (Wave >= 2)
	{
		lEnemy = dynamic_cast<Enemy*>(_Game->Spawn(new Enemy(), _Game->_Settings->Enemy2Texture, true, nullptr));
		lEnemy->SetHealth(_Game->_Settings->Enemy2Health);
		lEnemy->SetSpeed(_Game->_Settings->Enemy2Speed);
		lEnemy->SetSound(_Game->_Settings->EnemyDeathSound);
	}

	lEnemy->Activate();
}
开发者ID:h2ogit,项目名称:SFMLtest2-SM2d,代码行数:22,代码来源:EnemySpawner.cpp


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