how to cancel a animation and put an another

hi,

i would like to do this animation

transition.from( animation, { tag="deplacement", time=1100, x=-50, y=-50 } ) 

and after this do this animation below and cancel the previous animation

transition.scaleTo( animation,{tag = "animationpoussin", yScale=0, xScale=0,alpha=1, time=1200,delay =5000 } )

thanks for your help

To cancel a transition, you have to store a reference to the transition:

local myTransition = transition.from( animation, { tag=“deplacement”, time=1100, x=-50, y=-50 } )

then later:

transition.cancel(myTransition)

to cancel it.  Many people keep track of the transition in the object itself like:

animation.transition = transition.from( animation, { tag=“deplacement”, time=1100, x=-50, y=-50 } )

transition.cancel(animation.transition)

Rob

I tried what you described but with the scale transition my parameter is not interpreted and the animation is not stopped … you have an idea about the reason ?

local depl=transition.from( animation, { tag="deplacement", time=1100, x=-50, y=-50 } )   local sca=transition.scaleBy( animation, { tag="scaleanim", yScale=10, xScale=10, time=2000, x=2, y=2 } ) local function yes()     if animation.yScale \> 1 then transition.cancel(depl) transition.cancel(sca) end end timer.performWithDelay( 1200, yes)

What happens if you to a transition.to instead of a transition.scaleBy?  The .scaleBy version’s docs don’t list x and y as options.  That could be causing issues.

Rob

it’s the same the yes function does not work

local depl=transition.from( animation, { tag="deplacement", time=1100, x=-50, y=-50 } )   local sca=transition.to( animation, { tag="scaleanim", yScale=100, xScale=100, time=2000, x=2, y=2 } ) local function yes()     if animation.yScale \> 1 then transition.cancel(depl) transition.cancel(sca) end end

is there a way to stop a scale animation ? because all I have coded for my game is based on this principle

local box = display.newRect(100,100,10,10) local text = display.newText("", 250,100,native.systemFontBold,30) local t = transition.scaleBy(box, {time = 10000, xScale=10, yScale=10}) local seconds = 1 local function killIt()      print(box.xScale)      seconds = seconds + 1      text.text = seconds      if box.xScale \> 4 then           transition.cancel( t )      end end timer.performWithDelay(1000, killIt, 0)

This worked for me.  Perhaps you can compare and figure out what’s different.

Rob

yes it’s work i understand that wiht the print(box.scale)the function includes when to intervene

thanks and good night

hello sorry to bother you again …

I do not understand why my argument does not work … yet it is logical.

If time = 800 then you stopped the scalemin function but it does not work … you know tell me why?

thank you in advance :slight_smile:

local box = display.newRect(100,100,20,20) local text = display.newText("", 250,100,native.systemFontBold,30) local t = transition.scaleBy(box, {time = 1000, xScale=10, yScale=10}) local move = transition.to(box, {time=3000, x=300, y=200}) local seconds = 1 local function scalemin()   transition.scaleBy(box, {tag=scall, time = 1000, xScale=-0.5, yScale=-1}) end local function killIt()      print(box.xScale)      seconds = seconds + 1      text.text = seconds      if box.xScale \> 4 then           transition.cancel( t )           transition.cancel( move)           scalemin()       if time = 800 then         transition.cancel(scalemin)       end     end end timer.performWithDelay(1000, killIt, 0)

even this should work and no??

if seconds \> 4 then         transition.cancel( scall )       end

The tags are strings so should be surrounded by quotes. … tag = “scall”  … transition.cancel(“scall”) … etc

Then it should work.

Edit: I mean it should work after doing your _ seconds > 4 _ modification and fixing the tags.

_ time = 4000 _ does not work. You have not defined variable _ time _ anywhere.

thank you …so sometimes we search…and it’s a stupid mistake

pfouuuu it’s hard… one hour on that …
now i don’t understand why it doesn’t work

when my grid is displayed perfectly on the screen
You can not compare the value of a grid?

local function comparesscale() print(grille[2][4].yScale) if grille[2][4].yScale \> -0.1 then display.newRect(100,100,100,100) end end

Nobody ?

You need to show more code.  What is in those array cells?

this:

display.newRect(100,100,100,100)

creates a new rectangle, but it doesn’t store the reference to it, so you have no way of accessing it afterwards

hi, i have started a new topic where there is the full code :
http://forums.coronalabs.com/topic/49186-grid-problem-to-acces-a-value-of-a-cell/

To cancel a transition, you have to store a reference to the transition:

local myTransition = transition.from( animation, { tag=“deplacement”, time=1100, x=-50, y=-50 } )

then later:

transition.cancel(myTransition)

to cancel it.  Many people keep track of the transition in the object itself like:

animation.transition = transition.from( animation, { tag=“deplacement”, time=1100, x=-50, y=-50 } )

transition.cancel(animation.transition)

Rob

I tried what you described but with the scale transition my parameter is not interpreted and the animation is not stopped … you have an idea about the reason ?

local depl=transition.from( animation, { tag="deplacement", time=1100, x=-50, y=-50 } )   local sca=transition.scaleBy( animation, { tag="scaleanim", yScale=10, xScale=10, time=2000, x=2, y=2 } ) local function yes()     if animation.yScale \> 1 then transition.cancel(depl) transition.cancel(sca) end end timer.performWithDelay( 1200, yes)

What happens if you to a transition.to instead of a transition.scaleBy?  The .scaleBy version’s docs don’t list x and y as options.  That could be causing issues.

Rob

it’s the same the yes function does not work

local depl=transition.from( animation, { tag="deplacement", time=1100, x=-50, y=-50 } )   local sca=transition.to( animation, { tag="scaleanim", yScale=100, xScale=100, time=2000, x=2, y=2 } ) local function yes()     if animation.yScale \> 1 then transition.cancel(depl) transition.cancel(sca) end end