display position with text on the screen of the corona simulator ?

hi,

i have put a addEventListener on my background and i have two value

xbegin and xmiddle and i want to show these value on my screen.

with this code the value appears but the last value appears on the previous.

how do you do to refresh the value ?

txtXY = display.newText( "(\_\_\_,\_\_\_)", 45, 465, native.systemFontBold, 12 ) txtXY:setFillColor(1,0,0) local function showEvent( event ) txtXY.text = "(" .. xbegin .. "," .. xmiddle .. ")" end showEvent()

Hi @espace3d,

Where do you add the event listener, and what function does it call?

Brent

hi Brent,

here is my code if it could help you

local background = display.newRect (0, 0, 4000, 4000) local function printTouch( event )         print ("..event.x..","..event.y..")     end local function showEvent( event )     txtXY.text = "(" .. event.x .. "," .. event.y .. ")" end local function onTouch( event )     printTouch(event)     showEvent(event)     background:addEventListener( "touch", onTouch ) end txtXY = display.newText( "(\_\_\_,\_\_\_)", 45, 465, native.systemFontBold, 12 ) txtXY:setFillColor(0,1,0)

i have finded !!! now i could debug my code directly on my screen

local background = display.newRect (0, 0, 400, 400) local character =  display.newCircle( 100, 100, 30 ) txtXY = display.newText( "(\_\_\_,\_\_\_)", 45, 120, native.systemFontBold, 12 ) txtXY:setFillColor(0,1,0) background.touch = function( event )         if event.phase == "began" then print(event.x, event.y) txtXY.text = "(" .. event.x .. "," .. event.y .. ")"         end end Runtime:addEventListener( "touch", background.touch)

Hi @espace3d,

Where do you add the event listener, and what function does it call?

Brent

hi Brent,

here is my code if it could help you

local background = display.newRect (0, 0, 4000, 4000) local function printTouch( event )         print ("..event.x..","..event.y..")     end local function showEvent( event )     txtXY.text = "(" .. event.x .. "," .. event.y .. ")" end local function onTouch( event )     printTouch(event)     showEvent(event)     background:addEventListener( "touch", onTouch ) end txtXY = display.newText( "(\_\_\_,\_\_\_)", 45, 465, native.systemFontBold, 12 ) txtXY:setFillColor(0,1,0)

i have finded !!! now i could debug my code directly on my screen

local background = display.newRect (0, 0, 400, 400) local character =  display.newCircle( 100, 100, 30 ) txtXY = display.newText( "(\_\_\_,\_\_\_)", 45, 120, native.systemFontBold, 12 ) txtXY:setFillColor(0,1,0) background.touch = function( event )         if event.phase == "began" then print(event.x, event.y) txtXY.text = "(" .. event.x .. "," .. event.y .. ")"         end end Runtime:addEventListener( "touch", background.touch)