it's late here, I'm pretty tired - oh New Year's Day is coming . So just a short question: How do I use Gtween to a) constantly tween between two values - lets say alpha 1.0 to 0.0 and b) stop this tween at any time?
or perhaps this is more efficient but i did not test it:
function startPulsate(sprite) if not sprite.tween then sprite.tween=GTween.new(sprite, 0.5, {alpha=0}, {ease = easing.linear,reflect=true,repeatCount=0}) else sprite.tween:setPaused(false) end end
function stopPulsate(sprite) if sprite.tween then sprite.tween:setPaused(true) end end
Ah, cool, reflect plus count = 0 does the thing. Nice. Thanks for you help.
Btw: I clean up the tween after it ended. Just because I read somewhere, that Gtween holds a reference to the sprite and it doesn't feel to good to me...
i wonder if a sprite references its tween and the tween references the sprite, but they are not onscreen and nothing else references them, will they be ever garbage collected? also, does it matter if the tween is paused or not?
Comments
suppose that at the beginning the alpha is 1. then this will pulsate:
function startPulsate(sprite)
sprite.tween=GTween.new(sprite, 0.5, {alpha=0}, {ease = easing.linear,reflect=true,repeatCount=0})
end
function stopPulsate(sprite)
if sprite.tween then sprite.tween:stopAll() end
sprite.tween=nil
end
Fragmenter - animated loop machine and IKONOMIKON - the memory game
function startPulsate(sprite)
if not sprite.tween then sprite.tween=GTween.new(sprite, 0.5, {alpha=0}, {ease = easing.linear,reflect=true,repeatCount=0})
else sprite.tween:setPaused(false)
end
end
function stopPulsate(sprite)
if sprite.tween then sprite.tween:setPaused(true) end
end
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Btw: I clean up the tween after it ended. Just because I read somewhere, that Gtween holds a reference to the sprite and it doesn't feel to good to me...
also, does it matter if the tween is paused or not?
Fragmenter - animated loop machine and IKONOMIKON - the memory game