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


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

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


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

示例1: remove

/**
 * Remove off screen or colliding objects.
 * @param pEnemies Array of enemy objects that should be removed.
 */
void EnemyGenerator::remove(CCArray* pEnemies)
{
    CCObject* pObj;
    CCARRAY_FOREACH(pEnemies, pObj)
    {
        Enemy* pEnemy = (Enemy*)pObj;
		pEnemy->destroy();
    }
开发者ID:EricWang1992,项目名称:cocos2dx,代码行数:12,代码来源:EnemyGenerator.cpp

示例2: main

int main( int argc, char* args[] )
{
    bool quit = false;

    // Run Initialize Function
    if (GraphicsDevice::sInstance->init() == false)
    {
        std::cout << "ERROR: Could not Initialize." << std::endl;
    }

    if (FPSCounter::sInstance->init() == false)
    {
        std::cout << "Error: Could not FPS." << std::endl;
    }

    if (Interface::sInstance->init() == false)
    {
        std::cout << "ERROR: Could not Initialize." << std::endl;
    }

    // Load all Files
    if (load_files() == false)
    {
        std::cout << "ERROR: Could not Load Files." << std::endl;
    }

    // Event Handling
    while (quit == false)
    {
        // Apply Background to Game Screen
        if (background)
        {
            background->show_object(projectile, cannon);
        }

        if (Interface::sInstance)
        {
            Interface::sInstance->calculateMeter(cannon, projectile);

            // User Toggled Cannon Info Meters
            if (Interface::sInstance->interfaceIsShown())
            {
                Interface::sInstance->show_object(cannon);
            }
        }

        // User Toggled FPS Counter
        if (FPSCounter::sInstance->isShown())
        {
            GraphicsDevice::sInstance->apply_surface(GraphicsDevice::sInstance->getScreenWidth() / 1.25, 0, 0, 0, FPSCounter::sInstance->getFpsCounter(), GraphicsDevice::sInstance->getGameScreen());
        }

        if (GameManager::sInstance)
        {
            if (GameManager::sInstance->enemyList.size() < 4)
            {
                Enemy* enemy = new Enemy();
                enemy->setX(GameManager::sInstance->enemyList.back()->getX() + (rand() % 100) + 25);
                enemy->setY(projectile->getTrueY() * -1 + (rand() % 50));
                enemy->setImage("images/public enemy number 1.jpeg");
                enemy->setBounceAmount(500);
                GameManager::sInstance->enemyList.push_back(enemy);
            }
            for (int x = 0; x < GameManager::sInstance->enemyList.size(); x++)
            {
                GameManager::sInstance->enemyList[x]->show_object();
                GameManager::sInstance->enemyList[x]->move_object(projectile);
                if (GameManager::sInstance->enemyList[x]->getX() < -25)
                {
                    Enemy* e = GameManager::sInstance->enemyList[x];
                    GameManager::sInstance->enemyList.erase(GameManager::sInstance->enemyList.begin() + x);
                    e->destroy();
                    free(e);
                    break;
                }
            }
        }

        // Apply Cannon to Game Screen
        if (cannon)
        {
            cannon->show_object(projectile);
            // Check Launch State of Cannon
            switch(cannon->getLaunchState())
            {
                case 1: cannon->setPower();
            }

        }

        // Draw Projectile to Game Screen
        if (projectile->isShot())
        {
            projectile->show_object(cannon);
        }

        // Update the Screen
        if (SDL_Flip(GraphicsDevice::sInstance->getGameScreen()) == -1)
        {
            return 1;
//.........这里部分代码省略.........
开发者ID:minimucho1,项目名称:SampleCode,代码行数:101,代码来源:CannonMain.cpp


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