Function inside a button? Function inside a collision?

Hello,

I have some code (a function) that i want to add in a button/collision. But can’t seem to make it work, does any one know how? I want to press a button, then the function is activated and working. Same thing with the collision.

Thanks a lot for your help!

Code that i want to add in a collision and a button:

[code]

–The function i want to add:

local function clearLines(event)
for i = 1, #rectangle_hit, 1 do
rectangle_hit[i]:removeSelf()
rectangle_hit[i] = nil
end
end
Button Code:

local button2Press = function( event )

– Adding the function in the button didn’t seem to work?

end

local drop1 = ui.newButton{
default = “drop.png”,
over = “drop.png”,
onPress = button2Press,
emboss = true
}

drop1.x = display.contentWidth/14
drop1.y = display.contentHeight/1.1
drop1.rotation = -90
– Collision code:

ball.myName = “ball”
snow.myName = “snow”

ball:addEventListener(“collision”, ball)

function ball:collision (event)
if event.other.myName == “snow” then

– I want to add the function in the collision …?

end
end [import]uid: 23689 topic_id: 13433 reply_id: 313433[/import]

for a button its basic stuff:
[lua]local function button2Press(event)
if event.phase == “ended” then
clearLines()
end
end

button2:addEventListener(“touch”, button2Press)[/lua]

for collision its also basics
[lua]function onCollision (event)
if event.other.myName == “snow” then
clearLines()
end
end

ball:addEventListener(“collision”, onCollision)[/lua] [import]uid: 16142 topic_id: 13433 reply_id: 49342[/import]