i’m having a lot of issues setting a GUI node to a world position.
to start, i’m not using a standard render function.
here’s the one i’m using. the purpose of which is to allow the program to scale when the vertical size is changed, but change the aspect ratio when the horizontal size is changed. it also changes it so that the render output of a camera is centered on its position
local function fixed_fit_projection_no_scale(near, far, zoom)
zoom=1/zoom
local projected_width = render.get_window_width()
local projected_height = render.get_window_height()
local default_width=render.get_width()*zoom
local default_height=render.get_height()*zoom
local xs= zoom*projected_width/render.get_width()
local ys= zoom*projected_height/render.get_height()
local top=default_height/2
local bottom=-default_height/2
local left=-xs*default_width/(2*ys)
local right=xs*default_width/(2*ys)
return vmath.matrix4_orthographic( left, right, bottom, top, near, far)
end
as for the trouble with the gui nodes, i’m using a function that translates world position to the ui position
function worldtoscreen(x,y)
nx=1920/2 --the default screen size
ny=1080/2
nx=nx+((x*programdata.hs)-(19*32*programdata.hs))
ny=ny+((y*programdata.hs)-(15*32*programdata.hs)) --here programdata.hs is the horizontal scaling factor
return nx,ny
end
the trouble is that it’s not quite right.
this is what it look like at normal-ish scaling (the green dots are where the UI is thinking the tiles are)
but then it all falls apart once the screen is resized in a significant way
i’ve tried a lot of messing around with what’s being multiplied and the node scaling modes, but nothing seems to make it work as intended.