Posted 20 September 2013 - 11:44 AM
Hello com,
I'm working on a game and I want to check if the user has clicked a specific position on the screen. The position(s) is/are an image drawn with the paint program.
I want to check if the click was on the image.
I'm doing something like this but it don't works:
I'm working on a game and I want to check if the user has clicked a specific position on the screen. The position(s) is/are an image drawn with the paint program.
I want to check if the click was on the image.
I'm doing something like this but it don't works:
local img = paintutils.loadImage("someImage")
local clickCount = 1
local function draw()
while true do
paintutils.drawImage(img)
sleep(0.1)
end
end
local function click()
while true do
local _,btn,x,y = os.pullEvent()
if _ == "mouse_click" then
if img[y][x] == colors.brown then
clickCount = clickCount + 1
end
end
sleep(0)
end
end
Does anybody know what I'm doing wrong?