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 ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | -- 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 |
You are saying that if "line" collides with "line" then you want the function to trigger.
That's why it isn't working :)
Oooops, *****redOrb*****. That wasn't the problem though :/.... Even if i change that mistake, that was just a typo. It still doesn't work.