Contacts are true on the beginning of a game
Posted: Wed Oct 23, 2019 1:18 am
Greetings!
I'm trying to create a simple Dinossaur Game clone from the Google Chrome easter egg, but I'm facing a little problem.
As soon as the game starts, a contact callback is activated for a contact that has not been performed yet.
The variable playerLost is then set as true, even tho it is first defined as false, and not being touched in the rest of the code.
Any thoughts?
Thank you!
I'm trying to create a simple Dinossaur Game clone from the Google Chrome easter egg, but I'm facing a little problem.
As soon as the game starts, a contact callback is activated for a contact that has not been performed yet.
Code: Select all
function compareContacts(a, b, nameA, nameB)
if (a:getUserData() == nameA or a:getUserData() == nameB and b:getUserData() == nameA or b:getUserData() == nameB) then
textToPrint = tostring(true)
contactExists = true
return true
else
return false
end
end
function beginContact(a, b, coll)
if (compareContacts(a, b, 'player', 'ground')) then
textToPrint = tostring(true)
contactExists = true
end
if(compareContacts(a, b, 'player', 'block')) then playerLost = true end
end
Any thoughts?
Thank you!