• 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!

SOLVED health bar and border not lined up

G

Gudiwa

Guest
i was making a interface for my game and because there is screenshake present, i fixed the health bar border to: (x = view_xview+570 and y = view_yview+32) so that they would not be affected by the shaking. i also did the same thing to the health bar with some minor changes to the y coordinate: (x = view_xview+570 and y = view_yview+19). when the game is running the two are lined up perfectly. However when the screen shakes, the health bar seems to move along with the shaking resulting in misalignment.
 
G

Gudiwa

Guest
okay so i used the Draw GUI Event and i typed in draw_self(). But when it shakes, it reveals two drawn sprites

nvm. i just used another object to draw all the HUD objects
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
okay so i used the Draw GUI Event and i typed in draw_self(). But when it shakes, it reveals two drawn sprites
While you have solved this issue in another way, I feel I should address this for anyone else who comes to the topic... When you create an object with a sprite, GameMaker will "default draw" the sprite the same way as if you'd called draw_self() in the Draw Event. So if you have NO draw event, and add a Draw GUI event, the object will default draw the assigned sprite in the Draw Event as well as the sprite being drawn in the Draw GUI event. This can be avoided by either:

1) Adding a Draw Event and adding a simple comment like /// Event Override to the event and nothing else (this will stop the default drawing)
2) Not assigning a sprite to the instance and drawing things manual only in the Draw GUI event.
 

SoapSud39

Member
It might be that you're ordering your objects wrong. So let's say you have three objects (I'm making assumptions here): the health bar border, the health bar, and the object where screen shake occurs. Is it the case that the order of your object code is: health bar, screen shake, health bar border?
If your ui object comes after the screen shake object, it should follow it since the x/y changes on the same step, but if it comes before the screen shake then the x/y change will come the step after the screen shake step, making the ui 'follow' the camera. If it's not that, then maybe fixing the Draw GUI issue or posting some code would help.
(edit: didn't realize this was marked solved, but the above might help anyone else who has a similar problem to this that I had before)
 
Top