How to make a single click button
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 14
- Joined: Sat Aug 13, 2022 7:25 am
How to make a single click button
I want to make a button just like the white circle-shaped button used in google doodle championship (not the joystick but the button), I want the button to be single click........by that I mean on clicking that button, a variable "buttonClicked" will go true and instantly go false so that holding the button won't lead to repeating action, one more example is like the "btnp()" function used in tic 80, the player needs to click the button again and again instead of holding the button to repeat the action.....I hope you guys understood what I meant, Please help as soon as possible
- BrotSagtMist
- Party member
- Posts: 665
- Joined: Fri Aug 06, 2021 10:30 pm
Re: How to make a single click button
Code: Select all
Clicks=0
function love.mousepressed(x,y,b)
Press={x,y}
end
function button(x,y,r)
love.graphics.circle("line",x,y,r)
if Press then
if ((x-Press[1])^2+(y-Press[2])^2)<r^2 then
Press=nil
return true
end
end
end
function love.draw()
love.graphics.print(Clicks)
if button(160,160,60) then Clicks=Clicks+1 end
if button(300,30,20) then love.event.quit() end
end
obey
-
- Prole
- Posts: 14
- Joined: Sat Aug 13, 2022 7:25 am
Re: How to make a single click button
Thanks a lot it worked!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests