本文整理汇总了C++中CTime::asSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CTime::asSeconds方法的具体用法?C++ CTime::asSeconds怎么用?C++ CTime::asSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTime
的用法示例。
在下文中一共展示了CTime::asSeconds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void CProjectile::Update(CTime elapsedTime)
{
mShape.move(mVelocity * elapsedTime.asSeconds());
if (!IsActive())
{
mDeathTime -= elapsedTime;
if (mDeathTime <= CTime::Zero)
{
MarkAsDead();
}
}
}
示例2: Update
// =============================================================================
// CPullingSwing::Update
// -----------------------------------------------------------------------------
void CPullingSwing::Update(CTime elapsedTime)
{
DetachIfAnchorIsNotValid();
if (mAttached)
{
// Update the length since the player will be closer now
mLength = GetDistanceToBob();
// Detach the player if they are close enough
if (mLength <= smDetachLength)
{
Detach();
}
else
{
// Make sure the players velocity is towards the origin
CVector2f v = mBob->GetVelocity();
CVector2f bobToOrigin = mOrigin - mBob->GetPosition();
bobToOrigin.Normalise();
v = v.GetComponentInDirection(bobToOrigin);
// Accelerate the player towards the origin
float timedInc = smPullSpeedIncrement * elapsedTime.asSeconds();
CVector2f newV = v + (bobToOrigin * timedInc);
// Clamp the new velocity
if (newV.GetMagnitude() > smPullSpeedMax)
{
newV = bobToOrigin * smPullSpeedMax;
}
mBob->SetVelocity(newV);
}
}
}