S
skaiiwalker
Guest
I'm trying to build a civ6-esque real time strategy game, and it should always have a mouse interactable menu on the screen. I have a menu sprite attached to an object that follows the camera around when the player moves it, but for some reason I can't get it to scale with the viewport when the camera zooms in and out. So, you zoom out from the map, but the menu shrinks like you're zooming away from it too. Here's the code I'm using, if anyone can tell me why it isn't working I'll be very grateful.
To be clear, everything here works except for the image scaling
GML:
//obj_playerCamera create event
baseSpeed = 6;
cameraSpeed = 0;
minZoom = 1400;
maxZoom = 7000;
#macro camera view_camera[0]
#macro cameraX camera_get_view_x(view_camera[0])
#macro cameraY camera_get_view_y(view_camera[0])
#macro cameraW camera_get_view_width(view_camera[0])
#macro cameraH camera_get_view_height(view_camera[0])
GML:
//obj_playerCamera mouse wheel up event
if (cameraW > minZoom)
camera_set_view_size(camera, cameraW - (cameraW / 10), cameraH - (cameraH / 10));
GML:
//obj_playerCamera mouse wheel down event
if (cameraW < maxZoom)
camera_set_view_size(camera, cameraW + (cameraW / 10), cameraH + (cameraH / 10));
GML:
//obj_ui create event
camStartWidth = cameraW;
GML:
//obj_ui step event
x = cameraX;
y = cameraY;
GML:
//obj_ui draw event
image_xscale = camStartWidth / cameraW;
image_yscale = image_xscale;
draw_sprite(spr_ui, -1, x, y);