Game Development Reference
In-Depth Information
want to be sure that the graphics device is not in fullscreen mode, we can add the
following instruction:
graphics.IsFullScreen = false ;
Once we have changed the resolution, we need to tell the graphics device manager
that it should update the window. This is done by calling the ApplyChanges method:
graphics.ApplyChanges();
This way of setting the resolution does not take into account the actual screen di-
mensions. So let us try to come up with a method that handles this nicely. Especially
when we are in full screen mode, chances are that the actual resolution of the screen
is probably different from the desired resolution, we need to keep track of what the
desired resolution is and with what factor we should scale the sprites so that every-
thing is drawn correctly. In order to do that, we declare a member variable screen
inside the JewelJam class, together with a property to access it. We will use the type
Point for that, which is similar to a Vector2D type, except that it does not have vec-
tor manipulation methods, and the type of the coordinates is int . The declaration is
given as follows:
protected static Point screen;
Since there will probably be only one screen resolution in the game, we made this
variable and its associated property static . Inside the LoadContent method, we assign
a value to the screen member variable:
screen = new Point(1440, 1080);
Now we need to inform the graphics device that we would like to use this screen
resolution and we need to indicate if we want to run the game in full screen mode
or not. For that, we will add a method to the JewelJam class called SetFullScreen .
13.3 Updating the Graphics Device
The SetFullScreen method will have the following structure:
public void SetFullScreen( bool fullscreen = true )
{
...
if (!fullscreen)
{
Dealwithnonfullscreenmode
}
Search WWH ::




Custom Search