I am trying to do a collision where there is a 5 second window before the object is destroyed while the collision is still taking place.
I have a see-saw that can receive downward force events from either the right or left. If either the right or left part of the see-saw
touch the floor for more than five seconds than the game is over.
So if the right side of the see-saw is weighted down and touching the floor on the right side you want to press a button that will make a downward force event on the left side that will push down the left side of the see-saw and the right side will rise up off the floor. And if done within the five second timer the game will not be over.
So I have this…
function onCollision(event)
if event.other.name == ‘floor1’ then
local timer1 = timer.performWithDelay(5000, gameOver1, 1)
–seeSaw:setFillColor(255, 0, 0)
end
end
the seeSaw is the object/name with the collision listener. So once the right (or left) side of the seeSaw hits the ground it will bounce up and the game will be over in five seconds. I want that not to happen since the collision is no longer taking place.
As for the gameOver1 function. I tried doing something with another function that would call a display.remove(timer1) before the
gameOver1 function is called, but no dice. Is it possible to remove the onCollision function after it is called but before the
5 seconds and gameOver1 function is called?
Once the onCollision function is called there is no stopping the gameOver1 function from running. This is true?
if so I maybe going about this incorrectly.
Also I can get the seeSeaw to turn red when it hits the ground, but how would I get it back to normal when no longer hitting the floor?
Thanks in advance for any help.
russell
[import]uid: 75779 topic_id: 18588 reply_id: 318588[/import]
[import]uid: 52491 topic_id: 18588 reply_id: 71537[/import]