本文整理汇总了C#中Microsoft.Xna.Framework.GameTime.GetGameTick方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.GetGameTick方法的具体用法?C# GameTime.GetGameTick怎么用?C# GameTime.GetGameTick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.GameTime
的用法示例。
在下文中一共展示了GameTime.GetGameTick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyAcceleration
private Vector2 ApplyAcceleration( GameTime gameTime )
{
return Velocity = Utility.Limit( Velocity + Acceleration * gameTime.GetGameTick(), MaxVelocity );
}
示例2: CalculateVelocity
private void CalculateVelocity( GameTime gameTime )
{
var tick = gameTime.GetGameTick();
// apply gravity
var gravityVector = new Vector2( 0, FragEngineGame.Gravity * tick * GravityFactor );
Velocity += gravityVector;
// are we speeding up, or slowing down?
if( Acceleration != Vector2.Zero )
Velocity = ApplyAcceleration( gameTime );
else if( Friction != Vector2.Zero )
Velocity = ApplyFriction( gameTime );
}
示例3: ApplyFriction
private Vector2 ApplyFriction( GameTime gameTime )
{
var frictionDelta = Friction * gameTime.GetGameTick();
var newVelocity = Velocity;
if( Velocity.X - frictionDelta.X > 0 ) newVelocity.X -= frictionDelta.X;
else if( Velocity.X + frictionDelta.X < 0 ) newVelocity.X += frictionDelta.X;
else newVelocity.X = 0;
if( Velocity.Y - frictionDelta.Y > 0 ) newVelocity.Y -= frictionDelta.Y;
else if( Velocity.Y + frictionDelta.Y < 0 ) newVelocity.Y += frictionDelta.Y;
else newVelocity.Y = 0;
return Utility.Limit( newVelocity, MaxVelocity );
}
示例4: Update
public virtual void Update( GameTime gameTime )
{
CalculateVelocity( gameTime );
var partialVelocity = Velocity * gameTime.GetGameTick();
// ask the collision system if we're going to have a collision at that co-ord
var result = CollisionService.Check( Position, partialVelocity, BoundingBox );
UpdateEntityState( result );
}