Any way to cancel a running transition.to animation to rerun but with different parameters?

Given a transition.to animation which is currently running translating something on the screen and but user input, you need to reverse or change the current animation, which of course is not completed. Is there any way to do that?

I don’t want to transform transition.to into Runtime animation mechanics, because FPS is not warranted if I do manually so I wish go on with transition.to method.

Regards,

Flavio. [import]uid: 3022 topic_id: 869 reply_id: 300869[/import]

Hi,

store the tween inside the object like this:

myobject.mytween = transition.to (myonject, {…params…})

When you need to cancel the transition, use

transition.cancel(myobject.mytween)

I agree with you that transitions should be the way to go regarding transformations. But I got told ANSCA that using transitions intensively was not planned for corona. Plus after a while the more transitions you had running, the slower your app becomes. That is what i have experienced. [import]uid: 5712 topic_id: 869 reply_id: 1935[/import]

Thanks,

I will try it soon

Flavio [import]uid: 3022 topic_id: 869 reply_id: 1938[/import]

Well I just tried and doesn’t work as expected. It shows me an error and I think that error is because object is display.group, it seems that I can’t add object.property=transition.to to this special object.

Any idea?

Flavio [import]uid: 3022 topic_id: 869 reply_id: 1940[/import]

Sorry Flavio, but I can not see any problems regarding groups and assigning a value to them. Here is a sample code:

grp = display.newGroup()

local txt = display.newText( “Text1”, 0, 0, “Verdana-Bold”, 12 )
txt:setTextColor( 0,255,255 )
grp:insert(txt)

local txt2 = display.newText( “Text2”, 0, 20, “Verdana-Bold”, 12 )
txt2:setTextColor( 255,0,255 )
grp:insert(txt2)
grp.mytween=nil

local function onTouch(event)
if event.phase == “began” then
if grp.mytween ~= nil then
transition.cancel(grp.mytween)
end
grp.mytween = transition.to(grp,{time=1500, x=event.x, y=event.y})
end
end

Runtime:addEventListener( “touch”, onTouch )
[import]uid: 5712 topic_id: 869 reply_id: 1941[/import]

MikeHart,

Thank you by your code, but what I saw running this code is that Text1 & Text2 still moving even after touching the screen, but with a different velocity, so it doesn’t stop the transition. It should stop all movements but after touching texts still going to cursor position with a low velocity.

I need something that really stop the transition. In this case if texts start moving to cursor position, then after touching the screen they must stop where they are, without any new movements or velocity change.

Flavio. [import]uid: 3022 topic_id: 869 reply_id: 1951[/import]

Hi Flavio,

the sample code was to show that canceling a transition of a group does not throw errors. About the time factor,
I had a similar challenge in my game and there I calculated the distance to the new position first. Then used this result as a factor to calculate the time parameter.

But if I understood your last post correctly, do you want to stop the transition when your touch event is ended or cancelled?

Cheers
Michael [import]uid: 5712 topic_id: 869 reply_id: 1954[/import]