Hi,
I been having huge problems about transitions because apparently I can’t seem to cancel onComplete event on transitions. For example, in the ode:
local function whatever ( obj )
end
local trans = transition.to( something, { alpha = 0.0, time = 1000, onComplete = whatever } )
transition.cancel( trans )
function whatever will be called after 1 second even though the transition has been cancelled.
same thing apparently is happening with timers, for example:
local t = timer.performWithDelay( 1000, whatever )
timer.cancel ( t )
this will not prevent the timer to call the function whatever after 1 second.
since trans variable in above example is a table, i even tried to manually delete trans._onComplete and it doesn’t work (ie. the function will still be called after the transition time has expired).
is there any way to prevent the onComplete events from happening ?
thanks
n [import]uid: 48785 topic_id: 9914 reply_id: 309914[/import]
I obviously need it it’s just that under some conditions I want to cancel the transition and its onComplete event.
Important note: this problem occurs when used inside of modules loaded with Director class, it’s not possible to replicate if you put it in main.lua or in a module loaded directly from main.lua. So probably this post may be in the wrong category ? [import]uid: 48785 topic_id: 9914 reply_id: 36144[/import]
this problem occurs when used inside of modules loaded with Director class, it’s not possible to replicate if you put it in main.lua
I wish you mentioned that up-front, because I was poring over your code trying to see what’s wrong. [import]uid: 12108 topic_id: 9914 reply_id: 36180[/import]
ok i seem to find the problem, which was (as it usually happens) other part of code.
apparently the issue happened because I was assigning a transition to a variable more than once.
so if we do
trans = transition.to( something, { alpha = 0.0, time = 1000, onComplete = whatever } )
twice, there will be actually two transitions. one will be stored in trans variable and cancelled by
transition.cancel ( trans )
but the other one will no longer be accessible trough the trans variable.
with this code it works well
if not trans then
trans = transition.to( something, { alpha = 0.0, time = 1000, onComplete = whatever } )
end
but the real solution is of course taking care of the program flow to avoid unwanted calls ( which easily happens if forgetting to put “return true” at the end of touch methods, and similar … ).
sorry for crying wolf here. [import]uid: 48785 topic_id: 9914 reply_id: 36229[/import]