Problems with clicking menu buttons
Posted: Sat Jun 13, 2015 3:46 pm
Hey everybody. I am currently working on adding a menu to my game, however clicking buttons seems to do nothing. It's frustrating me now, because there is no error and I cannot find for the life of me a reason why this wont work. Here is the code.
And my mousepressed function:
Any ideas? Thanks.
Code: Select all
function button_click(x, y)
for i,self in ipairs (button) do
if x > self.x and
x < self.x + medium:getWidth(self.text) and
y > self.y and
y< self.y + medium:getHeight(self.text) then
if self.id == "quit" then
love.event.quit()
end
end
end
end
Code: Select all
function love.mousepressed(x, y)
if gamestate == "menu" then
button_click(x, y)
end
end