本文整理汇总了C++中Enemy::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::Initialize方法的具体用法?C++ Enemy::Initialize怎么用?C++ Enemy::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Enemy
EnemyManager::EnemyManager(char* filename, Ogre::SceneManager* _inMgr, Blocks* block_ent)
{
vData.clear();
vEnemy.clear();
ReadXmlEnemyData(filename);
for (int i = 0; i < vData.size(); i++) {
Ogre::Vector3 startPos = Ogre::Vector3(vData[i].x, vData[i].y, vData[i].z);
Ogre::Vector3 pos = block_ent->absToRealPos(startPos);
Enemy* enemy = new Enemy(_inMgr, Ogre::Vector3(pos.x, pos.y-25, pos.z), startPos);
vEnemy.push_back(enemy);
enemy->Initialize();
enemy->InitCmdVector(vData[i].vCmd);
}
}
示例2: AddEnemy
//=============================================================================================================
void Game::AddEnemy(int type, int height, int width, int track, int speed)
{
if( height > 3 || height < 1 )
return;
DummyFramework::CSprite9* sprite;
D3DXVECTOR2 position;
Enemy* enemy;
float h = (float)height;
float d = GameVariables::PlayFieldHeight;
float start = (GameVariables::ScreenHeight - d) * 0.5f;
float tw;
int cnt;
// elöször meg kell tudni, hogy melyik grafika lesz
switch( type )
{
case 0:
sprite = &atlas1["regular"];
break;
case 1:
sprite = &atlas1["worm"];
break;
case 2:
sprite = &atlas1["bomb"];
break;
case 3:
sprite = &atlas1["island"];
break;
/*
case 4:
sprite = &atlas1["elite"];
break;
*/
case 5:
sprite = &atlas1["razor"];
break;
default:
break;
}
// aztán kiszámolni a helyzetét
float yspacing = (d - 3.0f * sprite->Size.y) / 4.0f;
float xspacing = 20;
if( track == 0 )
{
position.y = start + yspacing + sprite->Size.y * 0.5f;
yspacing = (4.0f - h) * yspacing + (3.0f - h) * sprite->Size.y;
}
else if( track == 1 )
{
float center = start + d * 0.5f;
position.y = center - (h - 1) * 0.5f * (sprite->Size.y + yspacing);
}
else if( track == 2 )
{
position.y = GameVariables::ScreenHeight - start - yspacing - sprite->Size.y * 0.5f;
yspacing = -((5 - h) * sprite->Size.y + (4 - h) * yspacing);
}
// és létrehozni a megfelelö származtatott objektumot
switch( type )
{
case 0:
for( int i = 0; i < height; ++i )
{
position.x = GameVariables::ScreenWidth + sprite->Size.x;
for( int j = 0; j < width; ++j )
{
enemy = new Enemy();
enemy->shoot.connect(this, &Game::enemy_shoot1);
enemy->explode.connect(this, &Game::enemy_explode);
enemy->dead.connect(this, &Game::enemy_dead);
enemy->Initialize(*game);
enemy->Image = sprite;
enemy->Hurt = &atlas1["hurt"];
enemy->Speed = GameVariables::CorrelateW((float)speed);
enemy->SetPosition(position);
enemies.insert(enemy);
position.x += (sprite->Size.x + xspacing);
}
position.y += (sprite->Size.y + yspacing);
}
break;
case 1:
//.........这里部分代码省略.........