1. what is the best way to make a tween repeat infinitely? Currently I'm doing something like
tween.onComplete = function (self) self:setPosition(0);self:setPaused(false) end
or
repeatCount = math.huge
which works, but seems a bit hackish. Just wondering if there's a "right way".
2. more importantly: what's a good way to have a tween repeat back and forth a couple of times, then call a callback?
Practical example: scale an object from 1-3 and back 3-1, repeat the process three times, then call a callback. In this case I want to start a level zoomed out and pulsate the goal-sprite a couple of times to show where it is, then zoom back in to the player.
Do I need to setup a chain of callbacks or something manually, or is there a back-and-forth that can be used with repeatCount that I've missed?
Comments
1. I cannot find any other way except yours. Most probably I go with repeatCount = math.huge. It's totally valid. (math.huge-1 == math.huge)
Also, I've tried to make infinite loops with tween.nextTween = tween but I couldn't
2. You can use reflect = true
Come to think of it, I also think math.huge is a valid way to go about it, even better than -1 and similar that things like this often use in other libs.
I also couldn't chain the tween itself, which I guess it just as well. I think it doesn't rewind it but assumes it's at 0 when it starts. I think the advice should be math.huge instead of fixing that.
reflect also works just fine, though it surprised me a little that I had to double repeatCount - but that does allow for doing something 2.5 times, so probably a good thing.