touch event

Hey guys i was wondering is it possible to check the X and Y of where the player touches the screen?

example: if the player touches the screen on the right side of an object i want to addforce so it goes to the left and vise versa.

Could someone give me an example of how this works or a tutorial on this? if its possible!

Kind regards,

Jeroen

When you set up a touch event, the function that handles the event gets a table passed to it.  This is known as an “event” table (basically a table with some defined attributes).  The X and Y of the touch event are members of that table.

local function myTouchHandler( event )      print("phase", event.phase)      print("X", event.x)      print("Y", event.y)      return true end   someObject:addEventListener("touch", myTouchHandler)

See: http://docs.coronalabs.com/api/event/touch/index.html for all the members of the touch event table.

Awesome exactly what i needed thank you very much!

When you set up a touch event, the function that handles the event gets a table passed to it.  This is known as an “event” table (basically a table with some defined attributes).  The X and Y of the touch event are members of that table.

local function myTouchHandler( event )      print("phase", event.phase)      print("X", event.x)      print("Y", event.y)      return true end   someObject:addEventListener("touch", myTouchHandler)

See: http://docs.coronalabs.com/api/event/touch/index.html for all the members of the touch event table.

Awesome exactly what i needed thank you very much!