Hey,
I’m having a problem detecting if event has occurred, I’ve been trying to find a solution for a couple of days but google doesn’t seem to help so I will post here.
Basically what I’m trying to do is when user touches object1 it turns green (this one works) and then he can touch object2 and it will turn green too. Now, the problem comes if user doesn’t touch object1, in that case the second object (object2 in this case) should turn red on touch and I have no idea how to do so with separate functions…
for example;
function touchObject1()
object1:setFillColor(0, 128, 0)
end
object1:addEventListener( “touch”, touchObject )
function touchObject2()
if touchObject1 == true then
object2:setFillColor(0, 128, 0)
else
object2:setFillColor(0, 255, 0)
end
end
object2:addEventListener( “touch”, touchObject2 )
This first function works fine as you can see, but second one, the one with IF statement inside doesn’t work for whatever reason. I know it may be easier to put everything in the same function but it makes making the rest of the game 100 times… so if anyone knows how to solve this it’d be much appreciated.
Thanks!