本文整理汇总了C++中Projectile::SetVector方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::SetVector方法的具体用法?C++ Projectile::SetVector怎么用?C++ Projectile::SetVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::SetVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void Projectile::Update()
{
++mTicks;
if( (mPos.x <0) ||
(mPos.x>960)||
(mPos.y<0)||
(mPos.y>540))
{
mbIsDead = true;
}
switch(mpData->GetType())
{
case PT_Vector:
case PT_VectorGrenade:
mPos = mPos + mVector*mpData->GetSpeed();
break;
case PT_Custom:
break;
}
if(PT_VectorGrenade == mpData->GetType())
{
if(mTicks>mpData->GetFuse())
{
mbIsDead=true;
for(int it = 0; it<8;++it)
{
Projectile *pProjectile = ModContentManager::Instance().SpawnProjectile(mpData->GetShrapnelName());
Math::Vector2f refPosition = mPos;
int vec = 0+45*it;
refPosition += Math::Vector2f::GetVectorFromDeg(vec)*mpData->GetRadius();
pProjectile->SetPosition(refPosition);
pProjectile->SetVector(vec);
pProjectile->SetOwner(GetOwner());
if(PO_Enemy==GetOwner())
{
Game::Instance().QueueProjectile(pProjectile);
}
else if(PO_Player==GetOwner())
{
Game::Instance().QueueProjectile(pProjectile);
}
}
}
}
}
示例2: Update
void Player::Update()
{
mPosition += InputManager::Instance().GetDirection()*mSpeed;
if(mPosition.x<0){mPosition.x = 0;}
if(mPosition.y<0){mPosition.y = 0;}
if(mPosition.x>960){mPosition.x = 960;}
if(mPosition.y>540){mPosition.y = 540;}
// shoot
++ticks;
if(0==(ticks%rateOfFire))
{
Projectile *pProjectile = ModContentManager::Instance().SpawnProjectile("player_bullet");
Math::Vector2f refPosition = mPosition;
refPosition.x += 32;
pProjectile->SetPosition(refPosition);
pProjectile->SetVector(Math::Vector2f(1.f,0.f));
pProjectile->SetOwner(PO_Player);
Game::Instance().AddPlayerProjectile(pProjectile);
}
}