本文整理汇总了C++中Projectile::SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::SetPosition方法的具体用法?C++ Projectile::SetPosition怎么用?C++ Projectile::SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::SetPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Add
void Projectile::Add(Body *parent, Equip::Type type, const vector3d &pos, const vector3d &baseVel, const vector3d &dirVel)
{
Projectile *p = new Projectile();
p->m_parent = parent;
p->m_type = Equip::types[type].tableIndex;
p->SetFrame(parent->GetFrame());
parent->GetRotMatrix(p->m_orient);
p->SetPosition(pos);
p->m_baseVel = baseVel;
p->m_dirVel = dirVel;
p->m_radius = p->GetRadius();
Pi::game->GetSpace()->AddBody(p);
}
示例2: 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);
}
}
}
}
}
示例3: 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);
}
}
示例4: HandleUseSkill_
//==============================================================================
void GameServer::HandleUseSkill_(const QVariantMap& request, QVariantMap& response)
{
auto sid = request["sid"].toByteArray();
Player* p = sidToPlayer_[sid];
float x = request["x"].toFloat();
float y = request["y"].toFloat();
if (!x || !y)
{
WriteResult_(response, EFEMPResult::BAD_PLACING);
return;
}
Projectile* project = CreateActor_<Projectile>();
project->SetPosition (Vector2(p->GetPosition().x, p->GetPosition().y));
project->SetPoint(Vector2(x, y));
project->SetPlayer(p);
project->GetCoord ();
project->SetDirection (EActorDirection::EAST);
levelMap_.IndexActor(project);
WriteResult_(response, EFEMPResult::OK);
return;
}