Set Up Surface Views in GameMaker: Studio

By Michael Rohde

Basically, for this effect to work, you tell GameMaker: Studio to draw to a Surface the visible parts of a View, instead of drawing the View to the screen. You can tell GameMaker to draw the whole screen or a portion of the screen to the Surface every step of the game.

When you do this, you need to have two Views active simultaneously. If you don’t, then when the Surface is not drawn, the screen appears black, which is why you need the second View to display the screen.

Think of it this way: The first View appears initially, but when an Event is triggered — say, a shock wave rocks the player — the Surface effect kicks in and displays the Surface View with the shock wave effect. When the shock wave effect is finished, then the first View appears again.

The following procedure picks up with the in-software tutorial, Surfaces_Part2, found under the Advanced section of the Tutorials tab from the New Project window. To start, you set up the tutorial game to work with two different Views.

To set up two different Views, follow these steps:

  1. With the Surfaces tutorial open, from the Resource tree, double-click room0.

    The Room Properties appear.

  2. Click the Views tab.

  3. Select the Enable the Use of Views check box (see this figure).

    The Room Properties with Views enabled and visible.
    The Room Properties with Views enabled and visible.
  4. Select View 0 and make sure Visible When Room Starts is selected.

  5. Click to select View 1 and make sure Visible When Room Starts is selected.

  6. Click the green check mark.

    The Room Properties window is saved and closed.

With the Views set up, it’s time to create a new Surface Object. This Surface Object checks to see if the screen surface exists, and if so, it holds the values of the screen.