# Game Maker: How do I make a score display move with the view?

I have drawn everything needed to the screen including a HUD for the score, but I have my room set to follow my player: When the camera follows the player, the score HUD stays doesn't scroll with him!

How do I make the score display follow along with the player also?

You'll have to set the score position relative to the view position every update event.

Some basic pseudo code from what I remember of GML.

    score.x = view[0].x + 15;
score.y = view[0].y + 15;


You can do something similar with the drag and drop interface, but I haven't touched GameMaker for years so I can't help you with that.

• I think there is an option "relative to view" when you inspect the object in the room. Not sure though, been a few years for me as well (even before YoYo took over). – Kevin Apr 26 '13 at 12:48
• There's a new Draw GUI event that would be worth looking into: yoyogames.com/tech_blog/9 It would take care of doing all that relative stuff for you – Jeff May 21 '13 at 23:33

I added this to event draw, of the object Score and it worked for me

x= view_xview[0] + 320;
y= view_yview[0];
draw_set_font(fnt_score);
draw_set_color(c_white);
draw_text(x, y, (score));

• Welcome to GD.SE, Simon! Looking at your code, it's not obvious what everything actually does - for example, why is 320 added to view_xview[0]? It'd be great if you could edit your answer to explain your code. – Polar May 23 '14 at 18:33

@Simon was pretty close.

If you are trying to draw relative to the View that is Enabled you can use view_xview[view_current], view_yview[view_current].

For most situations you can get away with using view_xview[0] because most games do not utilize multiple views.

Have a look at the Draw GUI event for this particular problem.

I needed some left/right arrows on my screen to control player movement. I placed two buttons in the room, added a Draw event to each with nothing in it. I then added a Draw GUI event, with

draw_self();


as the only code in the event.

However, this only works for the full version.