GML Gui/Hud

P

PatatjeFriet

Guest
Hello,

So i am making a game where i want to have a gui following the room, but when i use the code for the object to follow the view it will have a delay in following. How do you prevent this from happening?

I'm using gamemaker 8.1
 

woods

Member
Drawing in the Draw GUI event starts at 0,0 (top-left of the screen) which is easier than plain old draw_text so you don't have to take the view's position into account.

but im not sure if its the same in 8.1 as it is in studio....

what do you have for your code so far?
 
P

PatatjeFriet

Guest
For now i only have this in step event:
Code:
//room view
self.x = view_xview;
self.y = view_yview;
I asked because I had the same issue in previous projects. In Gamemaker 8.1 you only have a Draw event and not Draw Gui.
 
Instead of setting the coordinate variables, cut out the middle man and just draw the text at the view variables. You also don't need "self" in this context.


You can also mimic the Draw GUI event by using an orthographic projection.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Pay close attention to the execution order.

If view_*view update before the Step event of that instance runs, everything will be fine.

If view_*view update after the Step event of that instance runs, it will be delayed by one frame.

View coordinates were updated between Step and End Step. Which event do you therefore have to run this code in to guarantee that there will never be a delay?


Another option is to handle drawing relative to view coordinates, not relative to the instance coordinates, therefore eliminating the need to update them constantly and not even giving things a chance to get delayed.

(Edit: God damn it BattleRifle)
 
P

PatatjeFriet

Guest
Thank you all so much!
It worked with me putting it into the draw event and i am really happy it finally works!
 
Top