I am using multiple “or” logical operators to check to see if the user’s finger has slipped off the button. The code is something like this:
if (event.phase == “moved”) then
eventX = event.x
eventY = event.y
if (eventX >= button.x + 75 ) or (eventX <= button.x - 75) or (eventY >= button.y + 75 ) or (eventY <= button.y - 75 ) then – perform action
Everything works fine, but I am wondering if using 4 “or” operators in one line is the best way to go, or if using multiple if statements would be better.
if (eventX >= button.x + 75) then
– perform action
elseif (eventX <= button.x - 75) then
--perform same action
elseif (eventY >= button.y + 75… etc.
Both will work, but which is faster and less resource hungry? I want to use this same concept to do some non-physics based collision detection.
Thanks in advance for your input.