• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

View help

andulvar

Member
I'd like to draw a view to the screen and then wrap that view with a HUD object so that none of the view gets cut off by the HUD.

Is there an easy way to manipulate the views to allow this? Or will I need to use surfaces and draw a smaller application surface into the HUD surface?
 

YoSniper

Member
The keywords view_xview and view_yview will help you draw/place objects and sprites relative to the view. For example, if you always want to draw a HUD on top of the view, you can say:

Code:
draw_sprite(sprite, index, view_xview, view_yview);
 

andulvar

Member
The keywords view_xview and view_yview will help you draw/place objects and sprites relative to the view. For example, if you always want to draw a HUD on top of the view, you can say:

Code:
draw_sprite(sprite, index, view_xview, view_yview);
Sure, but like I said doing that draws the HUD on top of the view and I want it around the view, not directly on top of it.
 

Alexx

Member
You can set up a port for part of the view manually (or in the room settings) and draw the GUI outside the port.

Edit, I see you want it wrapped, this is still doable, but probably only possible to do it in GML only.
 

Alexx

Member
Set up one view to your room dimensions, and draw your border wrapping / HUD, place another port inside this with your room.

If you need an example, provide your dimensions and I'll knock something up. Is the main view static or does it move?
 

Alexx

Member
Hi,
Here is a basic example, with separate view as the border set as 50 pixels.
www.gamemakerbook.com/GMZ/viewborder.gmz

You'll need to tweak it a bit, and maybe move the border down, really depends what happens in your game. You'll need to limit the y position of the object the view 1 follows, in this case obj_player, so that the border doesn't come into the main view 1.
 

andulvar

Member
This is a great example, but there are a number of problems for my own integration. The biggest is ensuring every room has reserved space for the HUD view, then there is the problem that view0 is already the main game view and I'd prefer to use view1 as the HUD layer (this seems more difficult to change than it first appeared), and then there is the issue that the main game window scaling gets messed up since it's 1600x900 native and some Draw GUI elements get offset incorrectly. I think I'll just have to live with drawing a HUD over the sides of the game.
 
W

whale_cancer

Guest
The biggest is ensuring every room has reserved space for the HUD view
The HUD is drawn outside of the main content of the room in the example. In my own use, I use GML to create the HUD elements directly outside of the room (putting backgrounds and objects for the HUD at room_width + int for instance; also doing this means you need to set the view information in GML rather than in the room properties). Thus, you never need to reserve an area in the room for the HUD.

then there is the problem that view0 is already the main game view and I'd prefer to use view1 as the HUD layer (this seems more difficult to change than it first appeared),
This really shouldn't be hard. Here is an example of my map editor hud...
Code:
window_set_size(1248, 720);

//view[0]
view_xview[0] = -128;
view_yview[0] = -104;
view_wview[0] = 768;
view_hview[0] = 720;

view_xport[0] = 480;
view_yport[0] = 0;
view_wport[0] = 768;
view_hport[0] = 720;

//view[1]
view_xview[1] = 0;
view_yview[1] = 0;
view_wview[1] = 480;
view_hview[1] = 720;

view_xport[1] = 0;
view_yport[1] = 0;
view_wport[1] = 480;
view_hport[1] = 720;

//view[2]
view_xview[2] = 0;
view_yview[2] = 0;
view_wview[2] = 416;
view_hview[2] = 416;

view_xport[2] = 32;
view_yport[2] = 272;
view_wport[2] = 416;
view_hport[2] = 416;
and then there is the issue that the main game window scaling gets messed up since it's 1600x900 native and some Draw GUI elements get offset incorrectly
I don't understand what you mean here.
 
Top