• 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 Making some images not scale with Camera Properties

C

Crysillion

Guest
What I'm trying to figure out is how I can make it so some images do not scale and will be represented 1:1 regardless of room view settings.

In example, my Viewport Properties are 1920x1080, however my Camera Properties are 960x540, thus everything in the game is scaled up by 2x. This is what I want for the majority of my game project.

However, when it comes to things such as UI or hud items, I would not want them to be zoomed in like this, as there are some rooms where the game is scaled differently (using the above method), and I don't want the UI/hud to scale with it as that would seem rather bizarre when actually playing the game.

I'm open to simply approaching camera properties in a different way if that's what is required, but if there's some way to have an image show 1:1 (as if Camera Properties and Viewport Properties are 1:1), then that's really what I'm looking for.

EDIT: I'm trying to accomplish this with instance_create_layer.



__________

Forgot to add. This is the Camera object I'm working with, in case that's relevant:

Create:
Code:
c_target = o_player;
c_width = camera_get_view_width(view_camera[0]);
c_height = camera_get_view_height(view_camera[0]);
c_scale = view_wport[0] / c_width;

End Step:
Code:
if not instance_exists(c_target) exit;
x = lerp(x, c_target.x, 0.15);
y = lerp(y, c_target.y-8, 0.15);
x = round_n(x, 1/c_scale);
y = round_n(y, 1/c_scale);
x = clamp(x, c_width/2, room_width-c_width/2);
y = clamp(y, c_height/2, room_height-c_height/2);
camera_set_view_pos(view_camera[0], x-c_width/2, y-c_height/2);

Room Start:
Code:
if !instance_exists(c_target) exit;
x = c_target.x;
y = c_target.y-8;
 
Last edited by a moderator:
C

Crysillion

Guest
Draw the UI to the GUI layer.
Sorry, I forgot to mention what's probably a pretty important part - getting this to work when using an instance creating command. Is there a way to instance_create_layer something onto the GUI?
 
A

arirish

Guest
You can draw anything to the GUI with the Draw GUI event, regardless of what layer the instance is on. Unless that's changed in GMS2
 
C

Crysillion

Guest
After doing some more research on the subject, it definitely seems like you can't put an object on the Draw GUI layer, and you wouldn't want to even if you could, so it seems the solution isn't that simple.

The wall I'm running into is particularly when you press a button on your keyboard to have something show up on the UI, like toggling an inventory or something of the sort. This is being done by utilizing instance_create_layer and objects. I'm certain there must be a way to have it so these particular objects' sprites don't scale with the Camera Properties, but googling around doesn't help me with the subject.
 
A

arirish

Guest
You can't put an object/instance there, but you can have an instance on a different layer that DRAWS to the GUI.
 
C

Crysillion

Guest
You can't put an object/instance there, but you can have an instance on a different layer that DRAWS to the GUI.
Right away I went to look if I couldn't just set an instances layer to draw to the GUI in the room itself, and didn't see it. Now, I'm not saying that's what you were getting at, I was just trying to figure it out. My eureka moment ended up being absolutely nothing. Can you elaborate on how one would go about drawing to the GUI like this?

I don't really see a way to do it in the instance_create_layer command itself.
 

rIKmAN

Member
After doing some more research on the subject, it definitely seems like you can't put an object on the Draw GUI layer, and you wouldn't want to even if you could, so it seems the solution isn't that simple.

The wall I'm running into is particularly when you press a button on your keyboard to have something show up on the UI, like toggling an inventory or something of the sort. This is being done by utilizing instance_create_layer and objects. I'm certain there must be a way to have it so these particular objects' sprites don't scale with the Camera Properties, but googling around doesn't help me with the subject.
Instead of using the Draw Event of the object to draw it, use the DrawGUI Event like BattleRifle said.

What layer the object is on is irrelevant, you can draw any object to the GUI Layer by using the DrawGUI Event and they won't be scaled with the normal camera, they will be drawn at a constant size according to how you setup the DrawGUI Layer (display_set_gui_size() etc)

Check out the DrawGUI section in the manual for Draw Events, the first line of which says:
The Draw GUI sub-event type falls under the Draw Event category and is specifically designed for drawing GUI (Graphical User Interface) elements that are not affected by the view scale or rotation.
 
Last edited:
C

Crysillion

Guest
Ah, right. This is definitely one of those "if it was a snake, it would've bit you" moments. I have no idea why that was so hard for me to comprehend.

Thanks for the help.
 

rIKmAN

Member
Ah, right. This is definitely one of those "if it was a snake, it would've bit you" moments. I have no idea why that was so hard for me to comprehend.

Thanks for the help.
Haha no worries, and don't be scared of the manual - it's not a snake, it's your friend! ;)
 
Top