Hello guys, Newbie here! I was working on a game that works on tiles as shown in the pic. Now the user should be able to move the tiles as they swipe in any direction ( up, down , left , right ). I am having problem swiping the box in the place of empty boxes as shown below.
I did try working on the code i found here : https://coronalabs.com/blog/2014/09/16/tutorial-swiping-an-object-to-fixed-points/
Code :
local LEFT = 50 local CENTER = display.contentCenterX local RIGHT = display.contentWidth - 50 local function handleSwipe( event ) if ( event.phase == "moved" ) then local dX = event.x - event.xStart --print( event.x, event.xStart, dX ) if ( dX \> 5 ) then --swipe right print("RIGHT ", dX) local spot = RIGHT if ( event.target.x == LEFT ) then spot = CENTER end transition.to( event.target, { time=500, x=spot } ) elseif ( dX \< -5 ) then --swipe left print("LEFT " , dX) local spot = LEFT if ( event.target.x == RIGHT ) then spot = CENTER end transition.to( event.target, { time=500, x=spot } ) end end return true end TileGroup:addEventListener( "touch", handleSwipe )
But no success
Any help?