transition.to effect

Hi

i have a game map which i can move left and right with a finger

is it possible to put in a elastic transition.to effect into the code below somehow

groupmap:insert(map1)
groupmap:insert(boat1)
groupmap:insert(boat2)

– touch listener function
function groupmap:touch( event )
    if event.phase == “began” then
 
        self.markX = self.x    – store x location of object
        self.markY = self.y    – store y location of object
        --myObject:toBack()
    elseif event.phase == “moved” then
 
        local x = (event.x - event.xStart) + self.markX
        local y = (event.y - event.yStart) + self.markY
        
        self.x = x  ---- move object based on calculations above
         
        
        --if self.x < 0 then
        --self.x=0
        --end

        if self.x < -500 then
        self.x= -500
        end

        if self.x > 300 then
        self.x= 300
        end

        --boat1:toFront()
        --myObject:toBack()
        
    end
    
    return true
end

groupmap:addEventListener( “touch”, groupmap )
 

I’m not sure what you’re asking. Do you want the group move into the right position after your finger is released?

Hi

basically when finger is released i would like it to stop to position with a transition effect

instead of just stopping

First, you’ll need a function to calculate the nearest appropriate position to move the group to. For example, if your three images are side by side and each 320 in width, then you’ll want to have the group move to one of the following x positions: 0, 320, 320*2.

Let’s say you have such a function called calculateX(), then in your touch function after you have handled the “move” phase, try something like this:

else transition.to(self, {x = calculateX(), time = 700, transition = easing.outSine})

I’m not sure what you’re asking. Do you want the group move into the right position after your finger is released?

Hi

basically when finger is released i would like it to stop to position with a transition effect

instead of just stopping

First, you’ll need a function to calculate the nearest appropriate position to move the group to. For example, if your three images are side by side and each 320 in width, then you’ll want to have the group move to one of the following x positions: 0, 320, 320*2.

Let’s say you have such a function called calculateX(), then in your touch function after you have handled the “move” phase, try something like this:

else transition.to(self, {x = calculateX(), time = 700, transition = easing.outSine})