Hi,
now I have built lots of games and published them so I think i know what I am doing but I am totally stuck with this, I really cannot see what I am wrong.
My collision handling isnt handling the carTop and bottom Collision. Well the carTop is colliding with the bottomrect which is a static object, but it inst removing the target i.e. the carTop. I know the condition isnt firing.
If I swap the elseif statement and ask if the phase has “began” it will work, but when I collide with other cars I always get a runtime error that the target in bottomrect/topcar condtion dosnt exist…pulling my hair out
here is the collision function.
[lua]
function carTop:collision(event)
local phase = event.phase
local target = event.target
local other = event.other
if phase == “began” then
if target.name == “carTop” and other.name == “carLeft” or
target.name == “carTop” and other.name == “carRight” or
target.name == “carTop” and other.name == “fireEngine2” or
target.name == “carTop” and other.name == “fireEngine3”
then
lives = lives - 1
display.remove(target)
target = nil
if lives < 1 then
physics.pause()
timer.performWithDelay(1500, gameOver)
end
end
elseif target.name == “carTop” and other.name == “bottomRect” then
display.remove(target)
target = nil
scoreNumber = scoreNumber + 10
updateScore()
end
end
[/lua]