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]