Swipe moves the image inside scene

Hi, I’m trying to make a game which the player will move the image (character) in three X position (left, center, right) with swipe i.e.

if player swipe finger from left to right and character is in left side should move to center, and if again swipe from left to right should get to right position and vice versa.

How I can achieve this with corona?

Please any help !!!

Thank You [import]uid: 197049 topic_id: 34409 reply_id: 334409[/import]

Didnt get to test it and wrote it in a rush so hope it works, but something like this:

currentScreen = 1 function moveCameraX( event) if event.phase == "ended" then if (event.x - event.xStart) \> 40 then currentScreen = currentScreen - 1 if currentScreen \< 1 then currentScreen = 1 end elseif (event.x - event.xStart) \< -40 then currentScreen = currentScreen + 1 if currentScreen \> 3 then currentScreen = 3 end end if currentScreen == 1 then transition.to( character, { time = 100, x = 80 } ) elseif currentScreen == 2 then transition.to( character, { time = 100, x = 160 } ) elseif currentScreen == 3 then transition.to( character, { time = 100, x = 240 } ) end end end Runtime:addEventListener( "touch", moveCameraX ) [import]uid: 77199 topic_id: 34409 reply_id: 136728[/import]

Thank You very very very much, it works very nice.

Best Regards [import]uid: 197049 topic_id: 34409 reply_id: 136757[/import]

Didnt get to test it and wrote it in a rush so hope it works, but something like this:

currentScreen = 1 function moveCameraX( event) if event.phase == "ended" then if (event.x - event.xStart) \> 40 then currentScreen = currentScreen - 1 if currentScreen \< 1 then currentScreen = 1 end elseif (event.x - event.xStart) \< -40 then currentScreen = currentScreen + 1 if currentScreen \> 3 then currentScreen = 3 end end if currentScreen == 1 then transition.to( character, { time = 100, x = 80 } ) elseif currentScreen == 2 then transition.to( character, { time = 100, x = 160 } ) elseif currentScreen == 3 then transition.to( character, { time = 100, x = 240 } ) end end end Runtime:addEventListener( "touch", moveCameraX ) [import]uid: 77199 topic_id: 34409 reply_id: 136728[/import]

Thank You very very very much, it works very nice.

Best Regards [import]uid: 197049 topic_id: 34409 reply_id: 136757[/import]