[Resolved] Can I call a Touch Event manually ?

Hi,

Basically when my App start you have to pick a section by pressing on a button from a selection of say 5.

Is there anyway in code I can call the function that button is calling (as if the button is pressed). I know I can just call the function but I need to somehow pass a touch event as in my function I use -

if “began” == event.phase then

A work a round is I could make a copy of the function without the event stuff and just call that once. But I hate duplicating code when I don’t have to.

So basically I need to call, with a touch event -

local function loadLevelOne( event )

Any ideas ?

Dave [import]uid: 117617 topic_id: 22897 reply_id: 322897[/import]

You can simulate that you’re giving the function an event.

Basically you define the event fields that you want your function to use:

local fakeEvent = {  
 phase = "began",  
 target = objectIWantToSimulateAsHavingBeenTouched,  
 x = 45,  
 y = 32  
}  

And then call the listener using that fake event:

loadLevelOne(fakeEvent) [import]uid: 61899 topic_id: 22897 reply_id: 91440[/import]

Cheers for that, simple when you know how.

Dave [import]uid: 117617 topic_id: 22897 reply_id: 91441[/import]