If there is no “official” way to do it, the only way I can think of is to do this is a bit clunky:
-
Loop through all of the objects to find out which ones are in the relevant xy position.
-
Manually call your touch function(s) passing in each of those objects as the target
local function getObjectsInClickPosition(x, y) --check objects and return table of all objects that are in the fake touch location --I’ll assume you have some code for checking positions already return objects end local fakeX, fakeY = 300, 160 local touchedObjects = getObjectsInClickPosition(fakeX, fakeY) for i = 1, #touchedObjects do myTouchFunction({target = touchedObjects[i], x = fakeX, y = fakeY, id = someFakeIDNumber, phase = “whateverPhaseYouNeed”}) end
Edit: You can also manually access the touch event associated with an object too, so you can call of the objects own functions rather than having one touch function with lots of if/elseif for different cases:
for i = 1, #touchedObjects do if touchedObjects[i].\_functionListeners then if touchedObjects[i].\_functionListeners.touch and touchedObjects[i].\_functionListeners.touch[1] then touchedObjects[i].\_functionListeners.touch[1]({target = touchedObjects[i], x = fakeX, y = fakeY, id = someFakeIDNumber, phase = "whateverPhaseYouNeed"}) elseif touchedObjects[i].\_functionListeners.tap and touchedObjects[i].\_functionListeners.tap[1] then touchedObjects[i].\_functionListeners.tap[1]({target = touchedObjects[i], x = fakeX, y = fakeY, id = someFakeIDNumber, phase = "whateverPhaseYouNeed"}) end end end