本文整理汇总了C++中CGameObject::SetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::SetPos方法的具体用法?C++ CGameObject::SetPos怎么用?C++ CGameObject::SetPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::SetPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCollision
void CScubaSolider::OnCollision(float deltaTime, std::vector<CGameObject*>* listObjectCollision)
{
float normalX = 0;
float normalY = 0;
float moveX = 0.0f;
float moveY = 0.0f;
float timeCollision;
if ((this->m_currentFrame == 0) || (this->m_currentFrame == 1))
{
return;
}
else
{
for (std::vector<CBullet*>::iterator it = CPoolingObject::GetInstance()->m_listBulletOfObject.begin(); it != CPoolingObject::GetInstance()->m_listBulletOfObject.end();)
{
CGameObject* obj = *it;
if (obj->IsAlive() && obj->GetLayer() == LAYER::PLAYER)
{
timeCollision = CCollision::GetInstance()->Collision(obj, this, normalX, normalY, moveX, moveY, deltaTime);
if ((timeCollision > 0.0f && timeCollision < 1.0f) || timeCollision == 2.0f)
{
// Gan trang thai die cho doi tuong
this->m_stateCurrent = SCUBAR_SOLIDER_STATE::SBS_IS_DIE;
// Xoa vien dan ra khoi d.s
CGameObject* effect = CPoolingObject::GetInstance()->GetEnemyEffect();
effect->SetAlive(true);
effect->SetPos(this->m_pos);
this->m_isALive = false;
it = CPoolingObject::GetInstance()->m_listBulletOfObject.erase(it);
//Load sound die
ManageAudio::GetInstance()->playSound(TypeAudio::ENEMY_DEAD_SFX);
// Tang diem cua contra len
CContra::GetInstance()->IncreateScore(1000);
}
else
++it;
}
else
++it;
}
}
}
示例2: OnCollision
void CBullet_ScubaSolider::OnCollision(float deltaTime, std::vector<CGameObject*>* listObjectCollision)
{
float normalX = 0;
float normalY = 0;
float moveX = 0.0f;
float moveY = 0.0f;
float timeCollision;
std::vector<CGameObject*>::iterator it;
// kiem tra co phai la vien dan dau tien hay k
if (!this->m_isFirstBullet)
{
for (it = listObjectCollision->begin();
it != listObjectCollision->end(); ++it)
{
CGameObject* obj = *it;
// Neu doi tuong la ground
if (obj->GetIDType() == 15 && (obj->GetID() == 1 || obj->GetID() == 8))
{
timeCollision = CCollision::GetInstance()->Collision(this, obj, normalX, normalY, moveX, moveY, deltaTime);
if ((timeCollision > 0.0f && timeCollision < 1.0f) || timeCollision == 2.0f)
{
if (normalY > 0)
{
if (this->m_vy <= 0)
{
// Gan trang thai die cho doi tuong
CGameObject* effect = CPoolingObject::GetInstance()->GetEnemyEffect();
effect->SetAlive(true);
effect->SetPos(this->m_pos);
this->SetAlive(false);
}
}
}
}
}
}
}