本文整理汇总了C++中CBase::GetCollisionRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CBase::GetCollisionRect方法的具体用法?C++ CBase::GetCollisionRect怎么用?C++ CBase::GetCollisionRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBase
的用法示例。
在下文中一共展示了CBase::GetCollisionRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void CBulletPaper::Update(float fElapsedTime)
{
CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
CGamePlay *pGP = CGamePlay::GetInstance();
SetPosX(GetPosX() + GetVelX() * fElapsedTime);
SetPosY(GetPosY() + GetVelY() * fElapsedTime);
rCollisionRect.top = GetPosY();
rCollisionRect.left = GetPosX();
rCollisionRect.bottom = GetPosY() + GetHeight();
rCollisionRect.right = GetPosX() + GetWidth();
CBase *player;
player = CPlayerCharacter::GetInstance();
RECT cross;
if (IntersectRect(&cross,&rCollisionRect,&player->GetCollisionRect()))
pMS->SendMsg(new CCollisionMessage(player,this));
if (GetPosY() > 580 || GetPosY() < -100 || GetPosX() > 740 || GetPosX() < -100)
pMS->SendMsg(new CDestroyMessage(this));
}
示例2: Update
void CBulletHook::Update(float fElapsedTime)
{
CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
CGamePlay *pGP = CGamePlay::GetInstance();
CPlayerCharacter *pPC = CPlayerCharacter::GetInstance();
if (GetScoreValue() == 1.0f)
{
m_fLifeTime -= fElapsedTime;
SetPosX(GetPosX() + GetVelX() * fElapsedTime);
SetPosY(GetPosY() + GetVelY() * fElapsedTime);
}
else if (GetScoreValue() == 2.0f)
m_fLifeTime -= fElapsedTime * 0.25f;
else if (GetScoreValue() == 3.0f)
{
m_fLifeTime -= fElapsedTime;
SetPosX(GetPosX() + GetVelX() * fElapsedTime);
SetPosY(GetPosY() + GetVelY() * fElapsedTime);
if (GetPosX() < pPC->GetPosX())
SetVelX(abs(GetVelX()));
else if (GetPosX() >= pPC->GetPosX())
SetVelX(-abs(GetVelX()));
if (GetPosY() < pPC->GetPosY())
SetVelY(abs(GetVelY()));
else if (GetPosY() >= pPC->GetPosY())
SetVelY(-abs(GetVelY()));
}
rCollisionRect.top = GetPosY();
rCollisionRect.left = GetPosX();
rCollisionRect.bottom = GetPosY() + GetHeight();
rCollisionRect.right = GetPosX() + GetWidth();
CBase *player;
player = CPlayerCharacter::GetInstance();
RECT cross;
if (IntersectRect(&cross,&rCollisionRect,&player->GetCollisionRect()))
{
pMS->SendMsg(new CCollisionMessage(player,this));
pMS->SendMsg(new CDestroyMessage(this));
}
if (m_fLifeTime <= 0)
pMS->SendMsg(new CDestroyMessage(this));
}