Hi everyone, I’ve got a problem
I wrote button “class”:
-- BUTTON Button = {} function Button:new() button = {} local rect = nil; function button:add(path, x,y, w,h) rect = display.newImage(path); ... end function button:getRect() return rect; end ... return button end return Button
And then I wrote this in main file:
joy2 = Button:new(); joy2:add("media/joy2.png", 15,display.contentHeight-60, 50,50);
I want to check the joy2 is touch, so:
function joy2:getRect():touch(event) // error joy2:getRect().x = 300; end joy2:getRect():addEventListener("touch", self);
But I’ve got error: unexpected symbol near ':'
How can I do that?