How do I make a button?
Posted: Sat Jul 29, 2017 6:18 pm
I really need help making a button, Ive been to the wiki but it doesnt help at all, can someone give me some assistance
Code: Select all
function love.mousepressed(x, y, button, istouch)
--the code that you write here gets called each time a mouse button is pressed
end
Code: Select all
function love.mousepressed(x, y, button, istouch)
if button == 1 then --checks which button was pressed, refer to [url=https://love2d.org/wiki/love.mousepressed]wiki[/url]
if x == 50 and y == 20 then
--do your stuff because the button was pressed
end
end
end
Code: Select all
function love.mousepressed(x, y, button, istouch)
if button == 1 then --checks which button was pressed, refer to [url=https://love2d.org/wiki/love.mousepressed]wiki[/url]
if x >= 50 and x <= 50+70 and y >= 20 and y <= 20+30 then
--do your stuff because the button was pressed
end
end
end
Code: Select all
function love.mousepressed(x, y, button, istouch)
if button == 1 then --checks which button was pressed, refer to [url=https://love2d.org/wiki/love.mousepressed]wiki[/url]
if math.sqrt((20-x)^2+(50-y)^2) <= 40 then
--do your stuff because the button was pressed
end
end
end
Code: Select all
function love.mousepressed(x, y, button, istouch)
if button == 1 then --checks which button was pressed, refer to [url=https://love2d.org/wiki/love.mousepressed]wiki[/url]
if ( ((20-x)^2)/70 ) + ( ((50-y)^2)/40 ) <= 1 then
--do your stuff because the button was pressed
end
end
end