[Original] Alex
When you use targetelapsedtime to change the screen refresh frequency too high and xNa cannot be reached, gametime. isrunningslowly = true;
Pass the gametime parameter to the update Method to Determine gametime. isrunningslowly
Code
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using Microsoft. xNa. Framework;
Using Microsoft. xNa. Framework. Audio;
Using Microsoft. xNa. Framework. content;
Using Microsoft. xNa. Framework. gamerservices;
Using Microsoft. xNa. Framework. graphics;
Using Microsoft. xNa. Framework. input;
Using Microsoft. xNa. Framework. Media;
Using Microsoft. xNa. Framework. net;
Using Microsoft. xNa. Framework. storage;
Namespace Alex
{
/// <Summary>
/// This is the main type for your game
/// </Summary>
Public Class Alexgame: Microsoft. xNa. Framework. Game
{
Graphicsdevicemanager graphics;
Spritebatch;
Public alexgame ()
{< br> graphics = New graphicsdevicemanager ( This );
content. rootdirectory = " content " ;
}
/// <Summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// Related content. Calling base. initialize will enumerate through any components
/// And initialize them as well.
/// </Summary>
Protected Override Void Initialize ()
{
// Todo: add your initialization logic here
// Set the number of refresh times caused by the ConferenceProgramError
This . Targetelapsedtime = Timespan. fromseconds ( 1.0f / 24000000f );
Base . Initialize ();
}
/// <Summary>
/// Loadcontent will be called once per game and is the place to load
/// All of your content.
/// </Summary>
Protected Override Void Loadcontent ()
{
// Create a new spritebatch, which can be used to draw textures.
Spritebatch = New Spritebatch (graphicsdevice );
//Todo: Use this. content to load your game content here
}
/// <Summary>
/// Unloadcontent will be called once per game and is the place to unload
/// All content.
/// </Summary>
Protected Override Void Unloadcontent ()
{
// Todo: unload any non contentmanager content here
}
/// <Summary>
/// Allows the game to run logic such as updating the world,
/// Checking for collisions, gathering input, and playing audio.
/// </Summary>
/// <Param name = "gametime"> Provides a snapshot of timing values. </Param>
Protected Override Void Update (gametime)
{
// Allows the game to exit
If (Gamepad. getstate (playerindex. One). Buttons. Back = Buttonstate. Pressed)
{
This . Exit ();
}
If (Keyboard. getstate (). iskeydown (Keys. Escape ))
{
This . Exit ();
}
// Displayed in the title bar but not running
This . Window. Title = Gametime. isrunningslowly. tostring ();
//Todo: add your update logic here
Base. Update (gametime );
}
/// <Summary>
/// This is called when the game shoshould draw itself.
/// </Summary>
/// <Param name = "gametime"> Provides a snapshot of timing values. </Param>
Protected Override Void Draw (gametime)
{
Graphicsdevice. Clear (color. cornflowerblue );
//Todo: add your drawing code here
Base. Draw (gametime );
}
}
}