Is there something wrong with my functions?

I have been playing with functions for over a week with no success. I have gotten down most of the Coron basics, but I can’t get anywhere further w/o figuring out what’s wrong with these functions. if anyone can point out what’s wrong it would be greatly appreciated:

local function functionName(event)  
 if(event.phase == "began") then  
 ball:remove(self)  
 end  
end  
floor.collision = functionName  
floor:addEventListener("collision", functionName)  

[import]uid: 7116 topic_id: 6054 reply_id: 306054[/import]

I am not a pro, but

  1. I think it is removeSelf() not remove(self)

  2. what the hell is the floor of a collision? “Floor” is used to determine the absolute value of a number, so i.e 1,234 becomes 1. [import]uid: 6587 topic_id: 6054 reply_id: 20758[/import]

Got it! I just hadn’t specified the coordinates of “hi”.

local function functionName(event) if(event.phase == "began") then local variable = display.newText("Hi", 100, 100) end end floor.collision = functionName floor:addEventListener("collision", functionName)

floor is the name for the rectangle representing the ground

local floor = display.newRect(0, 480, display.contentWidth , 1) [import]uid: 7116 topic_id: 6054 reply_id: 20813[/import]

ok I’ll change it to “ground” [import]uid: 7116 topic_id: 6054 reply_id: 20842[/import]

I know, what you meant with it, but you can’t use system variables for names.

floor is a system variable, that’s why it is blue in the code. Read what I wrote.

http://developer.anscamobile.com/node/3109

and even if it is not, what causes the problem, this is not OK for sure:

floor.collision = functionName floor:addEventListener("collision", functionName)

it should be

floor.collision = functionName floor:addEventListener("collision", floor) [import]uid: 6587 topic_id: 6054 reply_id: 20840[/import]

Actually that’s not correct. The first one works and the second one doesn’t. Unless mine is just really weird. [import]uid: 7116 topic_id: 6054 reply_id: 20852[/import]