本文整理汇总了C++中CBase::SetPosY方法的典型用法代码示例。如果您正苦于以下问题:C++ CBase::SetPosY方法的具体用法?C++ CBase::SetPosY怎么用?C++ CBase::SetPosY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBase
的用法示例。
在下文中一共展示了CBase::SetPosY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//.........这里部分代码省略.........