maybe we don't need onCompleteParams in that case (it'd also need onEnterFrameParams, on StartParams etc), so i'm keen to see how else it would be done
Hi @jmp909,
Yes, that is exactly what I mean. If you take a look towards the bottom of the main.lua in the app, you'll see that I've provided table and function listeners for all the events on both pausable transitions. If you were to add another value to one of the table listeners and print it within the table's function you'll get the functionality you're looking for.
It does feel a bit like going round the houses to get what, in other languages, would be a parameter in any situation, but in lua this is really a very straightforward solution and more powerful than it at first appears.
Let me know how you get on,
Matt.
but say you have two objects transitioning at the same time, both of which eventually call the same listener, how would you pass the same parameter for each but with different values?
in that case this is how i would have to do it currently
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| local rect = display.newRect(100,100,100,100)
rect:setFillColor(255,0,0)
local rect2 = display.newRect(100,100,100,100)
rect2:setFillColor(0,255,0)
local listeners = {}
function listeners:onComplete(obj)
print(listeners[obj].something)
end
listeners[rect]={something="whatever"}
listeners[rect2]={something="wherever"}
transition.to(rect, {time=1000, x=200, onComplete=listeners})
transition.to(rect2, {time=1000, y=200, onComplete=listeners}) |
@horacebury
Congratulations for your work on pausing transitions!
Thanks for sharing.
@jmp909 - Yes, you essentially have to use separate tables as the listeners. You'd have to do that anyway, as the unique parameters to the transitions would be separate tables, too.
@Magenda - Thanks. Let me know how you get on with it.
Matt.
this is great :D
Do you have any ideas how I can change the x param while the transition is running?
As with anything in lua, just set the value - the fact that a transition is running doesn't stop other values being modified.
M
yeah, but thats the problem .... i want to change the x value of the transition target :P
You want to change the target value of the transition? Then just cancel the transition and create a new one....
Just thinking about it further, if you're concerned about the change being obvious and not smooth enough, you can use an ease in the transition. Eg: http://developer.anscamobile.com/reference/index/easinginexpo
@horacebury
I am having trouble figuring out how to implement your class into my app! Any way you could provide some source code? Thanks a lot!
Yep, as per the first post, look at the download and it should be one line of code. I intended it to simply replace the usual transition.to:
https://files.me.com/horacebury/ueitx5
To cancel a pausable tween would you do this?
pausabletween:Pause()
pausabletween = nil
Thank you,
Daniel
If I remember correctly, yes - but check the sample main.lua which comes with the download.