Code: Select all
function love.draw()
love.graphics.scale(Width/720, Height/1280)
end
In the main menu, I have a button that is set to be in the middle of the screen when you press it, it is supposed to get you to the next screen, my problem is that when I resize the game from conf.lua for example change 720 to 360 and 1280 to 640 the "collision" detection with the mouse coordinates and the button coordinates don't mach. Here's the code:
Code: Select all
function menu:mousepressed(x,y,bytton,istouch)
if AABB(x,y,1,1, playBtn.x-playBtn.w/2,playBtn.y-playBtn.h/2,playBtn.w,playBtn.h) then
print("button pressed")
print(x .. " " .. y)
end
end
--On an different file
function AABB(x1,y1,w1,h1, x2,y2,w2,h2)
return x1 < x2+w2 and
x2 < x1+w1 and
y1 < y2+h2 and
y2 < y1+h1
end
Code: Select all
function menu:draw()
love.graphics.draw(bg,0,0)
love.graphics.draw(title.img,title.x,title.y,r,1,1,360,250)
love.graphics.draw(playBtn.img,playBtn.x,playBtn.y,0,1,1,playBtn.w/2,playBtn.h/2)
love.graphics.rectangle("line",playBtn.x-playBtn.w/2,playBtn.y-playBtn.h/2,playBtn.w,playBtn.h)
end