FrameRate.Update C# (CSharp) Method

Update() private method

private Update ( ) : void
return void
    private void Update()
    {
        TimeLeft -= Time.deltaTime;
        Accum += Time.timeScale / Time.deltaTime;
        ++Frames;

        if (TimeLeft <= 0)
        {
            FPSText.text = "Frame rate: " + (Accum / Frames).ToString("f2");
            TimeLeft = UpdateInterval;
            Accum = 0.0f;
            Frames = 0;
        }
    }

Usage Example

示例#1
0
 protected override void Draw(GameTime gameTime)
 {
     _frameRate.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
     SetWindowTitle($"{Math.Round(_frameRate.AverageFramesPerSecond)} fps");
     ScreenManager.Draw();
     base.Draw(gameTime);
 }
All Usage Examples Of FrameRate::Update