canceling functions

can someone help me on how to cancel a certain function on collision of 2 of more objects?
thank you [import]uid: 218976 topic_id: 35381 reply_id: 335381[/import]

What do you mean by “cancel a function”?

Lua is not multithreaded as such, so each piece of code is the only code executing at any time, so you can only cancel a function by leaving it.

If you mean that you have a timer or transition, then you should look in the documentation for timer.cancel(id) and transition.cancel(id)

If you can post a small example of your code which demonstrates the problem you’re having it would help. [import]uid: 8271 topic_id: 35381 reply_id: 140614[/import]

What I ment was, like from my previous post about swiping objects. If I swipe the object to go to the right and there is another object there already then I dont want the first one to go on top of the secind object. Like cancel that I told it to go there and just stay where it was. [import]uid: 218976 topic_id: 35381 reply_id: 140698[/import]

That’s not really cancelling a function - that’s just working out where something should be. Just calculate its position and put it there.

If something is in motion or being moved, say by a transition, you would probably want a timer or enterFrame event listener so you can check its position and stop it from being moved/changed. To actually stop it is simple - just have a variable which, when true, the animation continues. When false, the animation stops.

To stop a transition you would use transition.stop()

Do you have code you can post to demonstrate your problem? [import]uid: 8271 topic_id: 35381 reply_id: 140739[/import]

What do you mean by “cancel a function”?

Lua is not multithreaded as such, so each piece of code is the only code executing at any time, so you can only cancel a function by leaving it.

If you mean that you have a timer or transition, then you should look in the documentation for timer.cancel(id) and transition.cancel(id)

If you can post a small example of your code which demonstrates the problem you’re having it would help. [import]uid: 8271 topic_id: 35381 reply_id: 140614[/import]

What I ment was, like from my previous post about swiping objects. If I swipe the object to go to the right and there is another object there already then I dont want the first one to go on top of the secind object. Like cancel that I told it to go there and just stay where it was. [import]uid: 218976 topic_id: 35381 reply_id: 140698[/import]

That’s not really cancelling a function - that’s just working out where something should be. Just calculate its position and put it there.

If something is in motion or being moved, say by a transition, you would probably want a timer or enterFrame event listener so you can check its position and stop it from being moved/changed. To actually stop it is simple - just have a variable which, when true, the animation continues. When false, the animation stops.

To stop a transition you would use transition.stop()

Do you have code you can post to demonstrate your problem? [import]uid: 8271 topic_id: 35381 reply_id: 140739[/import]