transition status

Hi,

What’s the best way to change a transition?

A little scenario:
a ship is moving and the player select a new goal (tile) for the ship to move to.

The first thing is to check if the ship is doing a transition, and if this is true:
It’s a tile map so the transition have to go on to the middle of the next tile and after this i have to delete the old transition (transition.cancel()) and make an new transition to the new goal. right?

i tried the transition oncomplete function but this i don’t get it to work:

shiptransition = transition.to(ship1, {delay = mem ,time=900\*speed, x=xto, y=yto, onComplete=listener1 });  
  
local listener1 = function ( ship1 )  
 print( "Transition 2 completed on object: " )  
end  

thanks for the help!

wouter
[import]uid: 18622 topic_id: 32535 reply_id: 332535[/import]

Listener should be above transition in this code, for one thing- though to check if it is transitioning and cancel you’d do–

[lua]if transitionName then
transition.cancel(transitionName)
end[/lua]

[import]uid: 52491 topic_id: 32535 reply_id: 129403[/import]

Listener should be above transition in this code, for one thing- though to check if it is transitioning and cancel you’d do–

[lua]if transitionName then
transition.cancel(transitionName)
end[/lua]

[import]uid: 52491 topic_id: 32535 reply_id: 129403[/import]

Thanks for the reply

I have now

if shiptransition then
clicked = 1
Print(“is moving”)
End

In the same function above the transition code but the output is always ‘is moving’ even if the transition has already ended! [import]uid: 18622 topic_id: 32535 reply_id: 129459[/import]

Because shiptransition is not nil.

The transition already ended but shiptransition still exist. [import]uid: 31508 topic_id: 32535 reply_id: 129463[/import]

ah that makes sence!
so i have to make a bolean that is 1 when the transition starts and 0 when it ended.

Thanks for the answers, i will try to get it work :slight_smile: [import]uid: 18622 topic_id: 32535 reply_id: 129473[/import]

Thanks for the reply

I have now

if shiptransition then
clicked = 1
Print(“is moving”)
End

In the same function above the transition code but the output is always ‘is moving’ even if the transition has already ended! [import]uid: 18622 topic_id: 32535 reply_id: 129459[/import]

Because shiptransition is not nil.

The transition already ended but shiptransition still exist. [import]uid: 31508 topic_id: 32535 reply_id: 129463[/import]

ah that makes sence!
so i have to make a bolean that is 1 when the transition starts and 0 when it ended.

Thanks for the answers, i will try to get it work :slight_smile: [import]uid: 18622 topic_id: 32535 reply_id: 129473[/import]

its working until the transition.cancel:

transition.cancel( shiptransition )
shiptransition = nil

i have to set this to nil because the program uses if (shiptransition) then.

i get the runtime error 'attempt to index a nil value in function ‘cancel’.

i’ve been searching and trying since yesterday now but couldn’t find the solution (i don’t even know why the terminal is giving me this error). [import]uid: 18622 topic_id: 32535 reply_id: 130156[/import]

its working until the transition.cancel:

transition.cancel( shiptransition )
shiptransition = nil

i have to set this to nil because the program uses if (shiptransition) then.

i get the runtime error 'attempt to index a nil value in function ‘cancel’.

i’ve been searching and trying since yesterday now but couldn’t find the solution (i don’t even know why the terminal is giving me this error). [import]uid: 18622 topic_id: 32535 reply_id: 130156[/import]

Can you post your current code to look over? [import]uid: 52491 topic_id: 32535 reply_id: 130193[/import]

Can you post your current code to look over? [import]uid: 52491 topic_id: 32535 reply_id: 130193[/import]