Home | Aanpassen | Blog | Extra's | Log In | Info
Handleiding | D&D iconen | GML Parser | Archief | Iso City
Gebruikersnaam: Wachtwoord:  
Over ons | Features | Directory | Banners | Contact

Het ontwerpen van spellen met Game Maker
Het ontwerpen van spellen met Game Maker

Repainting the screen

Normally at the end of each step the room is repainted on the screen. But in rare circumstances you need to repaint the room at other moments. This happens when your program takes over the control. For example, before sleeping a long time a repaint might be wanted. Also, when your code displays a message and wants to wait for the player to press a key, you need a repaint in between. There are two different routines to do this.

screen_redraw() Redraws the room by calling all draw events.
screen_refresh() Refreshes the screen using the current room image (not performing drawing events).

To understand the second function, you will need to understand more fully how drawing works internally. There is internally an image on which all drawing happens. This image is not visible on the screen. Only at the end of a step, after all drawing has taken place, is the screen image replaced by this internal image. (This is called double buffering.) The first function redraws the internal image and then refreshes the screen image. The second function only refreshes the image on the screen.

Now you should also realize why you cannot use drawing actions or functions in other events than drawing events. They will draw things on the internal image but these won't be visible on the screen. And when the drawing events are performed, first the room background is drawn, erasing all you drew on the internal image. But when you use screen_refresh() after your drawing, the updated image will become visible on the screen. So, for example, a script can draw some text on the screen, call the refresh function and then wait for the player to press a key, like in the following piece of code.

{
  draw_text(room_width/2,100,'Press any key to continue.');
  screen_refresh();
  keyboard_wait();
}

Please realize that, when you draw in another event than the drawing event, you draw simply on the image, not in a view! So the coordinates you use are the same as if there are no views. Be careful when using this technique. Make sure you understand it first and realize that refreshing the screen takes some time.

When you are drawing the room yourself it can be useful to NOT let it be drawn automatic at all. For example, you might want to draw the room only every 5 steps. You can use the following functions for this:

set_automatic_draw(value) Indicates whether to automatically redraw the room (true, default) or not (false).

Finally there is a function with which you can set whether to synchronize the drawing with the refresh frequency of the monitor:

set_synchronization(value) Indicates whether to synchronize the drawing with the refresh frequency of the monitor.

You can also force a wait for the next vertical synchronization using the following function:

screen_wait_vsync() Waits for the next vertical synchronization of the monitor.

Zoeken Zoeken


Alternatieve versies Alternatieve versies

Je kan de handleiding ook lezen op een lange pagina (± 1.5 mb)

Ook beschikbaar in: Engels Frans Duits

ZIP Download helpfile

Advertentie Advertentie

GameMaker Handleiding