本文整理汇总了C++中CBase::SetImageID方法的典型用法代码示例。如果您正苦于以下问题:C++ CBase::SetImageID方法的具体用法?C++ CBase::SetImageID怎么用?C++ CBase::SetImageID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBase
的用法示例。
在下文中一共展示了CBase::SetImageID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleEvent
void CGamePlay::HandleEvent(CEvent *pEvent)
{
CSGD_ObjectFactory<string, CBase> *pOF = CSGD_ObjectFactory<string, CBase>::GetInstance();
CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
if (pEvent->GetEventID() == "spawn powerups")
{
CBase *tempPowerup;
int nRandomPowerup = rand() % 100 + 1;
if (nRandomPowerup <= 30)
tempPowerup = pOF->CreateObject("CPowerupHealth");
else if (nRandomPowerup > 30 && nRandomPowerup <= 60)
tempPowerup = pOF->CreateObject("CPowerupRapidFire");
else if (nRandomPowerup > 60 && nRandomPowerup <= 90)
tempPowerup = pOF->CreateObject("CPowerupThreeWay");
else if (nRandomPowerup > 90)
tempPowerup = pOF->CreateObject("CPowerup1up");
tempPowerup ->SetImageID(m_nImageID[3]);
tempPowerup->SetPosX(CPlayerCharacter::GetInstance()->GetPosX() + 128);
if (tempPowerup->GetPosX() > 640)
tempPowerup->SetPosX(640);
tempPowerup->SetPosY(CPlayerCharacter::GetInstance()->GetPosY() + 32);
pOM->AddObject(tempPowerup );
tempPowerup ->Release();
}
else if (pEvent->GetEventID() == "scroll right")
{
if (GetBridgeOffset() > -100)
{
SetBridgeOffset(GetBridgeOffset() - (5 * CGame::GetInstance()->GetSpeed()));
SetSpaceOffset(GetSpaceOffset() - (15 * CGame::GetInstance()->GetSpeed()));
for (int i = 0; i < enemies.size(); ++i)
{
enemies[i]->SetPosX(enemies[i]->GetPosX() - (5 * CGame::GetInstance()->GetSpeed()));
}
}
}
else if (pEvent->GetEventID() == "scroll left")
{
if (GetBridgeOffset() < 0)
{
SetBridgeOffset(GetBridgeOffset() + (5 * CGame::GetInstance()->GetSpeed()));
SetSpaceOffset(GetSpaceOffset() + (15 * CGame::GetInstance()->GetSpeed()));
for (int i = 0; i < enemies.size(); ++i)
{
enemies[i]->SetPosX(enemies[i]->GetPosX() + (5 * CGame::GetInstance()->GetSpeed()));
}
}
}
else if (pEvent->GetEventID() == "spawn enemies")
{
CBase *tempEnemy;
if (GetLevel() == 1 && m_nRemainingEnemies > 0 && m_nTotalSpawns < 10)
{
m_nEnemyCounter += 1;
m_nTotalSpawns += 1;
if (m_nTotalSpawns % 2 == 1)
{
tempEnemy = pOF->CreateObject("CEnemyDemon");
tempEnemy ->SetImageID(m_nImageID[1]);
pOM->AddObject(tempEnemy );
tempEnemy ->Release();
enemies.push_back(tempEnemy);
}
else
{
tempEnemy = pOF->CreateObject("CEnemyBusiness");
tempEnemy ->SetImageID(m_nImageID[1]);
pOM->AddObject(tempEnemy );
tempEnemy ->Release();
enemies.push_back(tempEnemy);
}
}
if (GetLevel() == 2 && m_nRemainingEnemies > 0 && m_nTotalSpawns < 10)
{
m_nEnemyCounter += 1;
m_nTotalSpawns += 1;
if (m_nTotalSpawns % 2 == 1)
{
tempEnemy = pOF->CreateObject("CEnemyMeat");
tempEnemy ->SetImageID(m_nImageID[2]);
pOM->AddObject(tempEnemy );
tempEnemy ->Release();
enemies.push_back(tempEnemy);
}
else
{
tempEnemy = pOF->CreateObject("CEnemyBooger");
tempEnemy ->SetImageID(m_nImageID[2]);
pOM->AddObject(tempEnemy );
tempEnemy ->Release();
enemies.push_back(tempEnemy);
//.........这里部分代码省略.........
示例2: CreateWeapon
CBase* Factory::CreateWeapon(int type, POINT mapPoint, bool bAddtoMngr)
{
CBase* weapon = new CBase();
CBase* temp;
switch(type)
{
case BOKKEN:
temp = weapons[BOKKEN];
temp->SetName("Bokken");
temp->SetImageID(CAssets::GetInstance()->aSwordID);
temp->SetNumType(0);
break;
case TACHI:
temp = weapons[TACHI];
temp->SetName("Tachi");
temp->SetImageID(CAssets::GetInstance()->aSwordID);
temp->SetNumType(1);
break;
case KATANA:
temp = weapons[KATANA];
temp->SetName("Katana");
temp->SetImageID(CAssets::GetInstance()->aSwordID);
temp->SetNumType(2);
break;
case NINJATO:
temp = weapons[NINJATO];
temp->SetName("Ninjato");
temp->SetImageID(CAssets::GetInstance()->aSwordID);
temp->SetNumType(3);
break;
case WOODNUN:
temp = weapons[WOODNUN];
temp->SetName("Wooden Nunchaku");
temp->SetImageID(CAssets::GetInstance()->aNunchakuID);
temp->SetNumType(4);
break;
case GLASSNUN:
temp = weapons[GLASSNUN];
temp->SetName("Glass Nunchaku");
temp->SetImageID(CAssets::GetInstance()->aNunchakuID);
temp->SetNumType(5);
break;
case STEELNUN:
temp = weapons[STEELNUN];
temp->SetName("Steel Nunchaku");
temp->SetImageID(CAssets::GetInstance()->aNunchakuID);
temp->SetNumType(6);
break;
case OAKSTAFF:
temp = weapons[OAKSTAFF];
temp->SetName("Oak Bo Staff");
temp->SetImageID(CAssets::GetInstance()->aStaffID);
temp->SetNumType(7);
break;
case BAMBOOSTAFF:
temp = weapons[BAMBOOSTAFF];
temp->SetName("Bamboo Staff");
temp->SetImageID(CAssets::GetInstance()->aStaffID);
temp->SetNumType(8);
break;
case STEELSTAFF:
temp = weapons[STEELSTAFF];
temp->SetName("Steel Staff");
temp->SetImageID(CAssets::GetInstance()->aStaffID);
temp->SetNumType(9);
break;
case RUSTYSAI:
temp = weapons[RUSTYSAI];
temp->SetName("Rusty Sais");
temp->SetImageID(CAssets::GetInstance()->aSaiID);
temp->SetNumType(10);
break;
case POLISHEDSAI:
temp = weapons[POLISHEDSAI];
temp->SetName("Polished Sais");
temp->SetImageID(CAssets::GetInstance()->aSaiID);
temp->SetNumType(11);
break;
}
weapon->SetWeapon(temp->GetName(),temp->GetStrength(), temp->GetDefense(), temp->GetImageID(), temp->GetNumType());
weapon->SetType(OBJECT_WEAPON);
weapon->SetWidth(32);
weapon->SetHeight(32);
if (bAddtoMngr)
{
//.........这里部分代码省略.........