You can use the Game.SupressDraw method for this purpose. From the remarks at the link:
Call this method during Update to prevent any calls to Draw until after the next call to Update. This method can be used on small devices to conserve battery life if the display does not change as a result of Update. For example, if the screen is static with no background animations, the player input can be examined during Update to determine whether the player is performing any action. If no input is detected, this method allows the game to skip drawing until the next update.
As an example, the following code will only call the Draw
function once. When I tested this I noticed that the CPU usage was high (70%) without the SuppressDraw
call. When using SupressDraw
, the CPU usage dropped dramatically (to less than 15%). Your numbers may vary.
public class Game1 : Microsoft.Xna.Framework.Game
{
...
private bool _drawn = false;
protected override void Update(GameTime gameTime)
{
if (_drawn)
SuppressDraw();
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
/* draw stuff here */
spriteBatch.End();
_drawn = true;
}
...
}
Note that SupressDraw
only suppresses one Draw
call. To prevent more calls to Draw
, you have to continually call SupressDraw
in Update
. Hopefully that makes sense.