当前位置: 首页>>代码示例>>C#>>正文


C# GameTime.GetTotalMilliseconds方法代码示例

本文整理汇总了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();
        }
开发者ID:DavidBasarab,项目名称:KidsSpace,代码行数:18,代码来源:Chapter2Game.cs

示例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;
        }
开发者ID:DavidBasarab,项目名称:KidsSpace,代码行数:20,代码来源:Sample1Game.cs


注:本文中的Microsoft.Xna.Framework.GameTime.GetTotalMilliseconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。