本文整理汇总了C#中Microsoft.Xna.Framework.GameTime.GetTotalMilliseconds方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.GetTotalMilliseconds方法的具体用法?C# GameTime.GetTotalMilliseconds怎么用?C# GameTime.GetTotalMilliseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.GameTime
的用法示例。
在下文中一共展示了GameTime.GetTotalMilliseconds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateCamera
private void UpdateCamera(GameTime gameTime)
{
Camera.Rotate(MouseState.DeltaX * .005f, MouseState.DeltaY * .005f);
var translation = Vector3.Zero;
if (KeyboardState.IsWDown) translation += Vector3.Forward;
if (KeyboardState.IsSDown) translation += Vector3.Backward;
if (KeyboardState.IsADown) translation += Vector3.Left;
if (KeyboardState.IsDDown) translation += Vector3.Right;
// Move 3 units per millisecond, independent of frame rate
translation *= 4 * gameTime.GetTotalMilliseconds();
Camera.Move(translation);
Camera.Update();
}
示例2: UpdateModel
private void UpdateModel(GameTime gameTime)
{
var rotationChange = new Vector3(0, 0, 0);
// Determin which axes the ship should be rotated on, if any
if (KeyboardState.IsWDown) rotationChange += new Vector3(1, 0, 0);
if (KeyboardState.IsSDown) rotationChange += new Vector3(-1, 0, 0);
if (KeyboardState.IsADown) rotationChange += new Vector3(0, 1, 0);
if (KeyboardState.IsDDown) rotationChange += new Vector3(0, -1, 0);
Models[0].Rotation += rotationChange * 0.025f;
if (KeyboardState.IsSpaceNotDown) return;
// Determine what direction to move in
var rotation = Models[0].CreateFromYawPitchRoll();
// Move in the direction dictated by our rotation matrix
Models[0].Position += Vector3.Transform(Vector3.Forward, rotation) * gameTime.GetTotalMilliseconds() * 4;
}