X Y relative Coordinates in touch event

Hi,

my screen is set to double the width of the visible display, allowing for swiping to move the camera from side to side. When a touch event occurs it’s event.x and event.y are relative to the current display, is there a technique to get the actual x,y coordinates so my objects don’t jump back to the true x,y of the level?

if I’m not clear please let me know.

thanks,

Pep [import]uid: 23182 topic_id: 30806 reply_id: 330806[/import]

“my screen is set to double the width of the visible display, allowing for swiping to move the camera from side to side.”

How so? Typically I control my camera by having all of my objects in a group which gives the same dilemma you mentioned. What I have to do is use an offset when referencing the touch events. I can’t remember the exact code(and I don’t have it with me) but I believe it’s something like this:

[lua]function myTouch(event)
xTouch = -myLevelGroup.x + event.x
yTouch = -myLevelGroup.y + event.y

–and then move whatever objects to your xTouch/yTouch
myDisplayObject.x = xTouch
myDisplayObject.y = yTouch

end[/lua]

If that doesn’t work then try playing around with the +/- on the xtouch/ytouch line.

Edit: apparently the cite tags don’t work! [import]uid: 147305 topic_id: 30806 reply_id: 123278[/import]

Many many thanks,.

Yep forgot to check my objectgroup coordinates for offset. Somedays the most elegant and simple just don’t come to mind.

Thanks again. [import]uid: 23182 topic_id: 30806 reply_id: 123280[/import]

“my screen is set to double the width of the visible display, allowing for swiping to move the camera from side to side.”

How so? Typically I control my camera by having all of my objects in a group which gives the same dilemma you mentioned. What I have to do is use an offset when referencing the touch events. I can’t remember the exact code(and I don’t have it with me) but I believe it’s something like this:

[lua]function myTouch(event)
xTouch = -myLevelGroup.x + event.x
yTouch = -myLevelGroup.y + event.y

–and then move whatever objects to your xTouch/yTouch
myDisplayObject.x = xTouch
myDisplayObject.y = yTouch

end[/lua]

If that doesn’t work then try playing around with the +/- on the xtouch/ytouch line.

Edit: apparently the cite tags don’t work! [import]uid: 147305 topic_id: 30806 reply_id: 123278[/import]

Many many thanks,.

Yep forgot to check my objectgroup coordinates for offset. Somedays the most elegant and simple just don’t come to mind.

Thanks again. [import]uid: 23182 topic_id: 30806 reply_id: 123280[/import]