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

GameMaker How do I make image scaling snap to the pixel grid?

Hi, I have a bar I want to use for a boss healthbar, but I'd like for it to snap to pixels, for consistency's sake in my game. (Trying to emulate the style of SNES at most, which I don't think had subpixel scaling, but I could be wrong.) Unfortunately, I can't figure out how to make this work. I'm thinking perhaps it involves dividing by the original pixel size of the bar, but from there, my mind is drawing a complete blank. I'm not even sure if this is the right path. Any advice one could give would be helpful! Also, in case it helps someone: This specific bar is currently 81 pixels wide (subject to change), so multiple sprites for each stage of the bar would be...very inefficient...
 

TheouAegis

Member
Well I mean, you could use image_xscale and the scale would be hp/maxhp if you had a monotone filler and the frame for the healthbar remained intact.

But if you want the whole healthbar to scale down without deformation or you have a multi-colored filler, then yeah you'd use draw_sprite_part(). It's a simple, straightforward function as long as you keep your scale factors 1.
 
T

Thunder Lion

Guest
Well I mean, you could use image_xscale and the scale would be hp/maxhp if you had a monotone filler and the frame for the healthbar remained intact.

But if you want the whole healthbar to scale down without deformation or you have a multi-colored filler, then yeah you'd use draw_sprite_part(). It's a simple, straightforward function as long as you keep your scale factors 1.
I use this very technique
 
Top