Search found 3 matches

by Mathamagic
Sun Apr 17, 2022 12:49 pm
Forum: Support and Development
Topic: How to detect a click on an image
Replies: 6
Views: 3650

Re: How to detect a click on an image

You can use love.mousepressed to detect mouse clicks, together with mouse position range checking like BrotSagtMist said, for example like this: local image = love.graphics.newImage("coolButton.png") local button = { image = image, x = 150, y = 100, width = image:getWidth(), height = imag...
by Mathamagic
Sun Apr 17, 2022 12:42 pm
Forum: Support and Development
Topic: How to detect a click on an image
Replies: 6
Views: 3650

Re: How to detect a click on an image

Unless you are tilting the image or give it cutouts this is just a simple range check: if love.mouse.isDown( button ) and MX>x and MX<x+width and MY>y and MY<y+height then Where MX/MY is the mouseposition you need to grab prior, x/y the picture position and you need to grab its size too. whenever i...
by Mathamagic
Sat Apr 16, 2022 6:34 pm
Forum: Support and Development
Topic: How to detect a click on an image
Replies: 6
Views: 3650

How to detect a click on an image

i am currently coding a game and i want to create a button with an image and i want it to draw something whenever it is pressed and ive looked at the wiki but i have no idea how to do it