Stop a transition.to on button click ?

When a user comes on the screen several transitions.to happen step by step

(when one is completed the other begins, total time=6000)

I want to stop the transitions from happening when a user clicks a button on the screen. 

How to achieve this result please?

Hi @blablu1212,

You can relate/associate multiple transitions by setting a common “tag” on them, similar to this:

[lua]

transition.to( square1, { time=1500, alpha=1, tag=“myTag” } )

transition.to( square2, { time=1500, alpha=1, tag=“myTag” } )

[/lua]

Then, you can manage all of these transitions collectively by using that tag value in other calls:

[lua]

transition.pause( “myTag” )

transition.resume( “myTag” )

transition.cancel( “myTag” )

[/lua]

Here is the documentation:

http://docs.coronalabs.com/api/library/transition/to.html

Hope this helps,

Brent

Thank you so much, your answers are so simple and efficient Brent :slight_smile:

hi Brent I’m completely new to this I’m taking an online class and this is like my 4th homework assignment and I am clueless about this…but I need to use the transition.to and I have to have like 4 different buttons with a start and a stop button and I’ve never done this before…if your allowed to help that’d be fine but if not its ok I can only load the buttons but have no idea how to get them to move at all

Hi @kself,

Which online course are you taking? Is it one that we officially promote on our site, or another course entirely?

http://coronalabs.com/resources/books/#online

Thanks,

Brent

Hi @blablu1212,

You can relate/associate multiple transitions by setting a common “tag” on them, similar to this:

[lua]

transition.to( square1, { time=1500, alpha=1, tag=“myTag” } )

transition.to( square2, { time=1500, alpha=1, tag=“myTag” } )

[/lua]

Then, you can manage all of these transitions collectively by using that tag value in other calls:

[lua]

transition.pause( “myTag” )

transition.resume( “myTag” )

transition.cancel( “myTag” )

[/lua]

Here is the documentation:

http://docs.coronalabs.com/api/library/transition/to.html

Hope this helps,

Brent

Thank you so much, your answers are so simple and efficient Brent :slight_smile:

hi Brent I’m completely new to this I’m taking an online class and this is like my 4th homework assignment and I am clueless about this…but I need to use the transition.to and I have to have like 4 different buttons with a start and a stop button and I’ve never done this before…if your allowed to help that’d be fine but if not its ok I can only load the buttons but have no idea how to get them to move at all

Hi @kself,

Which online course are you taking? Is it one that we officially promote on our site, or another course entirely?

http://coronalabs.com/resources/books/#online

Thanks,

Brent