Function triggers on collision

Hey,

Once my ball “redOrb” touches “line” then the ball is pulled towards it quickly. The only problem is a the moment the ball is pulled right when i relaunch the simulator… The function that pulls the ball towards “yellowOrb” is not what i’ve planned. I want the function to start once the ball touches “line”, i can’t add the function in the collision. So i’ve improvised and tried making gameLoop = false, once collision with 'line" it should = true. But for some reason did not work? I think that is the solution, is there any other way? Can any one help with this ?

[code]

– This is part of my code, did not add the objects on this bit. Just wanted to know how i can do this.

– Function that pulls redOrb towards yellowOrb.

local SPEED = 4

function gameLoop(event)
– constantly adjust velocity to track yellowOrb
redOrb:setLinearVelocity(
SPEED * (yellowOrb.x - redOrb.x),
SPEED * (yellowOrb.y - redOrb.y)
)
end

Runtime:addEventListener(“enterFrame”, gameLoop)

– Collision with ball “redOrb”

line.myName = “line”
redOrb.myName = “redOrb”

line:addEventListener(“collision”, line)

function line:collision (event)
if event.other.myName == “redOrb” then

– I want to add the function above to the collision.
– gameLoop = false? When touched line gameLoop = true? Tried but no success… Help?

end
end
[import]uid: 23689 topic_id: 12842 reply_id: 312842[/import]

You are saying that if “line” collides with “line” then you want the function to trigger.

That’s why it isn’t working :slight_smile: [import]uid: 52491 topic_id: 12842 reply_id: 47158[/import]

Oooops, *****redOrb*****. That wasn’t the problem though :/… Even if i change that mistake, that was just a typo. It still doesn’t work. [import]uid: 23689 topic_id: 12842 reply_id: 47200[/import]