Newbie here! Bear with me…
I have succeeded in creating a tap event with an event listener, and I have confirmed that things are working by printing to the console from within the function that is called by the listener. sorry if I destroyed any terminology there…
In order to create the next chunk of my app, what I think I need to do next is perform some checks within the function that is called when the thing is tapped. However, I cannot figure out how to pass information about the thing that was tapped into this function.
Basically, the user is tapping an image, and after the image is tapped I want to check whether or not the image he tapped was the “right” image. So right now my app displays 3 images, pulled from a table, and tapping any of them will call this one tappedEvent.
Here is the basic code that I’m talking about.
local function tappedEvent (event)
print ("something was tapped, this is tappedEvent function")
-- would like to check which image was tapped here
end
for i=1, 3 do
local imgThing = display.newImage( imageTable[i] )
imgThing.x = 160,
imgThing.y = i\*100+50
imgThing:addEventListener( "tap", tappedEvent )
localGroup:insert( imgThing )
end
Ideally I would like to pass the table index from imageTable that corresponds to the imgThing that was tapped up to the tappedEvent function, so tht I will know which of the 3 images was tapped.
Thanks for any advice! [import]uid: 191855 topic_id: 33751 reply_id: 333751[/import]