Scaled my game but the mouse coordinates have a problem
Posted: Mon Sep 12, 2016 11:16 pm
So I scaled my game graphics, everything I drew so that the game could fit in all resolutions based on an aspect ration. As a result of this the game could fit in all devices, however the problem is that i used a button code that works if the area inside of the buttons are pressed. After I scaled the graphics the buttons are scaled to a smaller or bigger size based on the resolution but the size and location of area of the inside of the button that triggers it stays the same.
How can I get the coordinates of the button area to "scale" as well.
This is my button code
Yes named my exit button "brexit" don't judge
How can I get the coordinates of the button area to "scale" as well.
This is my button code
Code: Select all
function love.mousepressed(mx,my,button)
bax = 15
bay = 15
bx = 615
by = 415
x = 500
y = 250
mx = love.mouse.getX()
my = love.mouse.getY()
if button == 1
and mx >= x and mx < x + play:getWidth()
and my >= y and my < y + play:getHeight() and click == false then
click = true --stuff to do when your image has been clicked
else if button == 1
and mx >= bx and mx < bx + brexit:getWidth()
and my >= by and my < by + brexit: getHeight() and click == false then
love.event.quit()
else if button == 1
and mx >= bax and mx < bax + back:getWidth()
and my >= bay and my < bay + back:getHeight() and click == true then
click = false
start = true
end
end
end
end