When running an app on the iPhone4 with multitouch activated, in a touch event handler where you set focus on the stage: the xStart and yStart values contain non-scaled values. For example if I click the middle of the screen and capture the touch event, x=160, but xStart=320.
main.lua
[code]system.activate(“multitouch”)
local background = display.newRect(0,0,display.viewableContentWidth,display.viewableContentHeight)
function background:touch( event )
if event.phase == “began” then
display.getCurrentStage():setFocus( event.target, event.id )
end
if event.phase == “ended” then
display.getCurrentStage():setFocus( event.target, nil )
print( “If you have clicked the screen without moving, then “…event.x…”==”…event.xStart…" and “…event.y…”=="…event.yStart )
end
end
background:addEventListener( “touch”, background )[/code]
config.lua
application =
{
content =
{
width = 320,
height = 480,
scale = "zoomEven",
},
}
Note the required conditions:
Must have multitouch activated
Must be setting focus for the touch event to the whole stage
Must be testing on the iPhone4 (iPhone4 simulator works too)
Must set the content size to 320x480 in config.lua with scaling on
To summarize, in this code, when you click the screen without moving, x should be the same as xStart, but it’s not.
Tested in build Version 2011.604 [import]uid: 35618 topic_id: 13852 reply_id: 313852[/import]