How can I print event.x and event.y

Hello…

I would like to know how can I make a function

that tells me the event.x and event.y of a point.

where ever i click with the mouse, on the screen on the simulator

I would like to know the exact .x and .y

and print it to the terminal

like

x = display.contentCenterX - 452

y = display.contentCenterY + 157

Thanks for your help

Victor

I got it

local function clickPoint( event ) local pointX = event.x pointX = pointX - 712 print(pointX) end Runtime:addEventListener( "touch", clickPoint )

The -712 is because that is the half of 1424

the size of the phone.

if you need the y just add this

local function clickPoint( event ) local pointX = event.x pointX = pointX - 712 print(pointX)   local pointY = event.x pointY = pointY - 400 print(pointY) end Runtime:addEventListener( "touch", clickPoint )

I just type - 400 more or less just to make a point

I hope this helps someone else

Victor

I have a more challenging question

like a real PRO!!!

I click on the simulator several times

and I get a list of numbers

-345, -300, -200, -50, 12, 36, 235, 500 and so on

I have in my App a table with many values

I need this table to make part of my app work

    values = {           -365, -306, -250,     -174, -118,  -61,   -3,       73,  128,  186,  242,      318,  375,  431,  489,           -423, -365, -306, -250,     -174, -118,  -61,   -3,       73,  128,  186,  242,      318,  375,  431,  489      }

Right now, (after a lot of thinking)

I get the numbers from the terminal after I click on the correct place

and “manually” I have to type the same numbers inside my values table…

I am sure there is a way that I can just “click” on the simulator

save the list of “clicks” or numbers in some place

like

place = list of "clicks" -365, -306 ... and so on

And then like “magic”

“automatically” right after the last click

  values = {   place   }      

the program will put all the list of numbers

inside my value table, without me

having to type all of them manually

wouldn’t that be nice?

Would you know how to to this

and help me with this problem

it will save me hours and hours of programming

Thank you very much

Victor

Hello, So when you press and get the value you could write it to a string and put that string in to a table.

I know not very useful to just just tell you to do that without code but i don’t have much time so cant really code anything at the moment.

Good Luck!

At least that a start…thanks.

“So when you press and get the value you could write it to a string”

How do I put that in to a “string”

anybody knows that?

I got it

local function clickPoint( event ) local pointX = event.x pointX = pointX - 712 print(pointX) end Runtime:addEventListener( "touch", clickPoint )

The -712 is because that is the half of 1424

the size of the phone.

if you need the y just add this

local function clickPoint( event ) local pointX = event.x pointX = pointX - 712 print(pointX)   local pointY = event.x pointY = pointY - 400 print(pointY) end Runtime:addEventListener( "touch", clickPoint )

I just type - 400 more or less just to make a point

I hope this helps someone else

Victor

I have a more challenging question

like a real PRO!!!

I click on the simulator several times

and I get a list of numbers

-345, -300, -200, -50, 12, 36, 235, 500 and so on

I have in my App a table with many values

I need this table to make part of my app work

    values = {           -365, -306, -250,     -174, -118,  -61,   -3,       73,  128,  186,  242,      318,  375,  431,  489,           -423, -365, -306, -250,     -174, -118,  -61,   -3,       73,  128,  186,  242,      318,  375,  431,  489      }

Right now, (after a lot of thinking)

I get the numbers from the terminal after I click on the correct place

and “manually” I have to type the same numbers inside my values table…

I am sure there is a way that I can just “click” on the simulator

save the list of “clicks” or numbers in some place

like

place = list of "clicks" -365, -306 ... and so on

And then like “magic”

“automatically” right after the last click

  values = {   place   }      

the program will put all the list of numbers

inside my value table, without me

having to type all of them manually

wouldn’t that be nice?

Would you know how to to this

and help me with this problem

it will save me hours and hours of programming

Thank you very much

Victor

Hello, So when you press and get the value you could write it to a string and put that string in to a table.

I know not very useful to just just tell you to do that without code but i don’t have much time so cant really code anything at the moment.

Good Luck!

At least that a start…thanks.

“So when you press and get the value you could write it to a string”

How do I put that in to a “string”

anybody knows that?