本文整理汇总了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();
}
示例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;
//.........这里部分代码省略.........