I have
local line = display.newLine( sceneGroup, 0,_H-1, _W, _H-1)
line:setStrokeColor(1,0,0,1)
line.strokeWidth=8
line.myName=“Floor”
sceneGroup:insert(line)
physics.addBody(line, “static”, {isSensor = True}) – I was reading add body and I thought that would help.
I copied this function from Nick Sherman (thanks Nick!)
function touchCircle(event)
local obj = event.target
local cid = obj.id
local objective = obj.objective
if event.phase == “began” then
print (“Circle number " … cid … " was clicked!”)
print ("objective is " … objective)
end
I called that function with
c:addEventListener(“touch”, touchCircle)
So, right after c:addEventListener(“touch”, touchCircle)
I added
c:addEventListener(“collision”, CollisionWithLine)
Then I tried to add function just like he did but using the info from your documentation
function CollisionWithLine(event)
local obj = event.target – I will worry about these later.
local cid = obj.id – I will worry about these later.
local objective = obj.objective – I will worry about these later.
–I found out I had to put this in here because as soon as I created the circles this function was being called. I assume collision with background??? but it was nil for object1. No idea why. But the problem is that when the circle touches the line I still get nothing in object1. But then it does some strange things on my screen. Likes stops but the text in the circle move backwards. VERY strange.
if (event.object1 == nil) then
print(“nothing in object1”)
return false
end
if (event.object2 == nil) then
print(“nothing in object2”)
return false
end
if event.phase == “began” then
print (“Circle number " … cid … " collided with line!”)
print ("obj1 is " … event.object1.myName … " obj2 is " … event.object2.myName)
print ("objective is " … objective)
end
end
Any ideas what I am doing wrong?
Thanks!
It just gets frustrating.