I'm currently working with the love2D game engine and am curious how to create just a simple user menu. Maybe just with a few options such as: Play, options, about, exit.
Are there any good tutorials out there for creating a custom game menu? I just want to get started.
To make a basic menu system, this is what you could do:
love.draw, loop through that table and draw the buttonslove.update (also possible in .draw if you want), check if the mouse is hovering over the buttonNow I can't give you all the code needed, because it depends on the rest of your code. However, I can give you a function to check if the mouse is hovering a button:
function pointInRectangle(pointx, pointy, rectx, recty, rectwidth, rectheight)
return pointx > rectx and pointy > recty and pointx < rectx + rectwidth and pointy < recty + rectheight
end
And the logic behind checking if the user has pressed the mouse:
love.load, add pressed = falselove.mousereleased, add pressed = truelove.draw, just before end, add pressed = falseNow, if pressed equals true, you know that the user has just released the mouse button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With