• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows [SOLVED] New way to make HUD follow the screen?

M

mont266

Guest
Hi!

In GMS1.4 I always drew my HUD using this code:
Code:
draw_healthbar(view_xview[0]+32,view_yview[0]+32,view_xview[0]+256,view_yview[0]+50,global.playerhealth,c_black,c_red,c_green,0,false,true);
But I am aware that this no longer works for making my healthbar follow the view.

I have tried:
Code:
view_camera
and
Code:
view_xport
but still can't get the HUD to move with the camera. Can anyone help me with a new way to tackle this?

Cheers!
 

Tsa05

Member
Code:
var cam = view_camera[view_current];

var vx = camera_get_view_x(cam);
var vy = camera_get_view_y(cam);
var vw = camera_get_view_width(cam);
var vh = camera_get_view_height(cam);
 
M

mont266

Guest
Code:
var cam = view_camera[view_current];

var vx = camera_get_view_x(cam);
var vy = camera_get_view_y(cam);
var vw = camera_get_view_width(cam);
var vh = camera_get_view_height(cam);
Thanks! I tried messing about with the values and I sorted it, but im stuck with another problem, it technically 'follows' the camera but it stretches the bar out along with the camera? Am I doing something wrong?

My code is here:
Code:
draw_healthbar(vx+32,vy+32,vw-1664,vh-1030,global.playerhealth,c_black,c_red,c_green,0,false,true);
 

Tsa05

Member
Ah, I don't think you need vw and vh in this case. Those are just the width and height of your view.
Looks like you wanted to go from the corner+32 to the corner +256

draw_healthbar(vx+32,vy+32,vx+256,vy+50,global.playerhealth,c_black,c_red,c_green,0,false,true);
 
M

mont266

Guest
Ah, I don't think you need vw and vh in this case. Those are just the width and height of your view.
Looks like you wanted to go from the corner+32 to the corner +256

draw_healthbar(vx+32,vy+32,vx+256,vy+50,global.playerhealth,c_black,c_red,c_green,0,false,true);
Thank you so much! It's taking me a little time to adapt to GMS2 from GMS1.4, but im getting there. If I could hug you I would! Thanks a lot!
 
Top