|
||
ViewsAs you should know you can define up to eight different views when designing rooms. A view is defined by its view area in the room and its viewport on the screen (or to be precise in the drawing region within the window). Using views you can show different parts of the room at different places on the screen. Also, you can make sure that a particular object always stays visible.You can control the views from within code. You can make views visible and invisible and change the place or size of the views in the drawing region or the position and size of the view in the room (which is in particular useful when you indicate no object to be visible). You can change the size of the horizontal and vertical border around the visible object, and you can indicate which object must remain visible in the views. The latter is very important when the important object changes during the game. For example, you might change the main character object based on its current status. Unfortunately, this does mean that it is no longer the object that must remain visible. This can be remedied by one line of code in the creation event of all the possible main objects (assuming this must happen in the first view):
The following variables exist that influence the view. All, except the first two are arrays ranging from 0 (the first view) to 7 (the last view).
view_enabled Whether views are enabled or not. Note that the size of the image on the screen is decided based on the visible views at the beginning of the room. If you change views during the game, they might no longer fit on the screen. The screen size though is not adapted automatically. So if you need this you have to do it yourself, using the following functions:
window_set_region_size(w, h, adaptwindow) Set the width and height of the drawing region in the window. adaptwindow indicates whether the window size must be adapted if the region does not fit in. The window size will always be adapted if you use fixed scaling. (See the function window_set_region_scale().) In a game you often need the position of the mouse cursor. Normally you use for this the variables mouse_x and mouse_y. When there are multiple views, these variables give the mouse position with respect to the view the mouse is in. Sometimes though, you might need the mouse position with respect to a particular view, also when it is outside that view. For this the following functions exist.
window_view_mouse_get_x(id) Returns the x-coordinate of the mouse with respect to the view with index id.
|
||





