I'm following the book Microsoft XNA Game Studio Creators Guide v2. and there is a snippet in the book that is used to return a Rectangle that represents the safe area you can draw without the fear of 'drawing' outside the screen.

Except in my IDE Visual Studio 2010, that method doesn't show up in intellisense and in fact doesn't show up anywhere.

Here is the snippet:

private void UpdateAsteroid(GameTime gameTime)
    // time between frames
    float timeLapse = (float)gameTime.ElapsedGameTime.Milliseconds;
    if (move == true)
    { // asteroid centered at the middle of the image
        Rectangle safeArea = TitleSafeRegion(rockWidth/2, rockHeight/2);

      // asteroid right edge exceeds right window edge
    if (rockPosition.X > safeArea.Right){
        rockPosition.X = safeArea.Right; // move it back
        rockSpeed *= -1.0f; // reverse direction
// asteroid left edge precedes the left window edge
else if (rockPosition.X - rockCenter.X < 0){
rockPosition.X = rockCenter.X; // move it back
rockSpeed *= -1.0f; // reverse direction
// asteroid within window bounds so update rockPosition
rockPosition.X += rockSpeed * timeLapse;
// Scale radians by time between frames so rotation is uniform
// rate on all systems. Cap between 0 & 2PI for full rotation.
const float SCALE = 50.0f;
rockRotation += rockRotationSpeed * timeLapse/SCALE;
rockRotation = rockRotation % (MathHelper.Pi * 2.0f);

2 Answers 2


Hey guys, I am also reading the same book, and that method is defined as a procedure in the game class ( File Game1.cs) as

Rectangle TitleSafeRegion( int spriteWidth, int spriteHeight )
    #if XBOX
    // some televisions only show 80% of the window
    [... code here ...]
    // ensure image drawn in safe region on all sides
    return new Rectangle( [... code here ...] );

    // show entire region on the PC or Zune
    return new Rectangle( 0, 0, [... Code here ...] );

It isn't part of Viewport, the author implemented his own method to show compatibility with XBOX, PC, and Zune. It is found on Chapter 4, page 44. Hope this answered your question. Sorry, for the late post.


Are you sure that method isn't defined earlier in the book? From your calling code example it's an instance/static method of the class that UpdateAsteroid is a member of - it doesn't appear in MSDN as a member of the Game class (for 4.0 or 3.1).

Alternatively, Viewport.TitleSafeArea property might help.

  • \$\begingroup\$ Now something weird is happening. The Viewport bit is recognized, but as I type Titl- nothing appears on the Intellisense as if that helper property doesn't even exist. Then if I just manually type it in and wait a bit, it's detected and mouseover gives me the information for it. \$\endgroup\$
    – Sergio
    Commented Oct 12, 2010 at 2:07
  • \$\begingroup\$ Hm that is strange. Intellisense could just be lagging. Try forcing it by pressing Ctrl+Space. The normal candidates for missing intellisense like missing references and using directives would generally cause compile errors... \$\endgroup\$
    – jeffora
    Commented Oct 12, 2010 at 2:48
  • \$\begingroup\$ TitleSafeArea is an instance method if Viewports, it sounds like you're trying to use it as a static method on the Viewport class. \$\endgroup\$
    – Martin
    Commented Oct 12, 2010 at 20:49
  • \$\begingroup\$ Ah yeh as Martin said, the class you're writing your code in probably has a Viewport property i.e. public Viewport Viewport { get; } so when you type 'Viewport.' you get the static intellisense (which doesn't include TitleSafeArea - an instance property) and when you type in manually it resolves to the instance property Viewport (and its instance property TitleSafeArea) \$\endgroup\$
    – jeffora
    Commented Oct 13, 2010 at 1:06

You must log in to answer this question.