Touch events for mesh buttons

Then you could do something like what I show below. Where I have 200,50 in buttons, you would change that to whatever x,y value you need. You can do any additional calculations in the Button:init function that you need.


buttons[#buttons+1]=Button(200,50,readImage("Cargo Bot:Menu Button"),menu)


function Button:init(x, y, buttonImage, callbackFunction)
    -- you can accept and set parameters here
    self.mesh = mesh()
    self.mesh.texture = buttonImage
    cw,ch=spriteSize(buttonImage)
    self.mesh:addRect(x,y,cw,ch)
    self.mesh:setRectTex(1,0,0,1,1)
    self.buttonCorner1 = vec2(x-cw/2,y-ch/2)
    self.buttonCorner2 = vec2(x+cw/2, y+ch/2)
    self.callbackFunction = callbackFunction
end