[SOLVED] Using Push scaling library with SUIT GUI, can't align Mouse position
Posted: Sat Jul 13, 2019 12:19 am
I'm wanting to design my game at 1920,1080 because thats what my art dude said he's most comfortable working at.
Initially I was worried, as I would have rather just sclaed up the game, but after seeing the PUSH scaling libray:
https://github.com/Ulydev/push I thought it would be easy to scale the game to different resolutions and thought that was the end of my worries.
At 1920x1080 the game looks and works fine, all the things scale perfectly with lower resolutions even with the SUIT designed UI, the UI reacts when the mouse goes over it etc...
However, if I scale the resolution down to 1280x720 its as if there is a mouse offset to the right. I can no longer hover over the button to select it but have to select it around 400+ pixels to the right (and down).
I tried to use the code recommended in the Push library of push:toGame to give scaled coordinates, but it doesn't prevent the offset, it just updates the mouse coordinates to scale to the internal resolution (rather than the screen resolution coordinates I would get if I just used love.mouse.getPosition).
Any ideas on how to solve this conundrum? Ultimately i'd rather have a keyboard controlled UI anyway, but until I get some art i'm working with placeholder GUI's so I can make an abstracted version of the game.
Here's some code showing what I'm working on, i've snipped out the bits I don't think are relevant though.
Sorry for the poor code, if its easier I can just upload the whole file(s) but i'd rather not plague you with my spaghetti -testing things out- code.
Initially I was worried, as I would have rather just sclaed up the game, but after seeing the PUSH scaling libray:
https://github.com/Ulydev/push I thought it would be easy to scale the game to different resolutions and thought that was the end of my worries.
At 1920x1080 the game looks and works fine, all the things scale perfectly with lower resolutions even with the SUIT designed UI, the UI reacts when the mouse goes over it etc...
However, if I scale the resolution down to 1280x720 its as if there is a mouse offset to the right. I can no longer hover over the button to select it but have to select it around 400+ pixels to the right (and down).
I tried to use the code recommended in the Push library of push:toGame to give scaled coordinates, but it doesn't prevent the offset, it just updates the mouse coordinates to scale to the internal resolution (rather than the screen resolution coordinates I would get if I just used love.mouse.getPosition).
Any ideas on how to solve this conundrum? Ultimately i'd rather have a keyboard controlled UI anyway, but until I get some art i'm working with placeholder GUI's so I can make an abstracted version of the game.
Here's some code showing what I'm working on, i've snipped out the bits I don't think are relevant though.
Code: Select all
main.lua file
function love.load()
window_width, window_height = 1920,1080
window_set_up(window_width,window_height, false) (just a basic set up function that contains the Push window set up code)
--states
gamestate.registerEvents()
gamestate.switch(menu)
end
function love.update(dt)
end
function love.draw()
push:start()
mouseX, mouseY = love.mouse.getPosition()
mouseX, mouseY = push:toGame(mouseX, mouseY)
suit.draw()
push:finish()
end
menu.lua file
menu = {}
--window_width = 1920
--window_height = 1080
function menu:update(dt)
if input:pressed("space") then suit.Button("Start Game",860, 190, 200, 200).hit = true end
if input:pressed("esc") then love.event.quit() end
if suit.Button("Start Game", 860, 190, 200, 200).hit == true
then
gamestate.switch(game)
end
end
function menu:draw()
suit.Label(mouseX.."\n"..mouseY, mouseX+15,mouseY+15, 100,100)
end