I have an image that I want to grow and shrink. I’ve gotten this far with the code:
transition.to( cat1, { time=2000, x=417, y=619, alpha=1, delay=0, transition= easing.linear, xScale =2, yScale = 2, rotation = 0 })
local myclosure\_cat1 = function() transition.to(cat1, {time=1000, x = 417, y=619, alpha=1, delay=0, transition= easing.linear, xScale=1, yScale=1, rotation=0 }) end
timer.performWithDelay(500, myclosure\_cat1, 1)
This makes it grow and shrink once. How do I make it grow / shrink forever?
Demetrius
[import]uid: 1380 topic_id: 12249 reply_id: 312249[/import]
I did something like this and it works:
local function repeatGrow (event)
transition.to( cat1, { time=500, x=417, y=619, alpha=1, delay=0, transition= easing.linear, xScale =2, yScale = 2, rotation = 0 })
local myclosure\_cat1 = function() transition.to(cat1, {time=500, x = 417, y=619, alpha=1, delay=0, transition= easing.linear, xScale=1, yScale=1, rotation=0 }) end
timer.performWithDelay(500, myclosure\_cat1, 1)
end
-- Grow image every second (0 = infinity) using transition.to()
timer.performWithDelay(1000, repeatGrow, 0 )
I used that fade in and out transition example to achieve this.
Demetrius
[import]uid: 1380 topic_id: 12249 reply_id: 44621[/import]
Wouldn’t this recursive call create infinite timers? and if that so that means that it will crash your app, isn’t it?
[import]uid: 12407 topic_id: 12249 reply_id: 44622[/import]
I don’t know. I’m sure there’s a better way of doing it.
That’s why I posted the code hoping that someone would suggest
a better solution.
If you know of a better way please tell me.
Demetrius [import]uid: 1380 topic_id: 12249 reply_id: 44625[/import]
how about calling them from one another?
[lua]local Call_trans1,Call_trans2
function Call_trans1()
transition.to(obj1, …,onComplete=Call_trans2}
end
function Call_trans2()
transition.to(obj1, …,onComplete=Call_trans1}
end
Call_trans1()[/lua]
or if you want it to just grow forever, (which seems a bit strange but whatever you want to do)
[lua]local theScale=1
local growIt
local function growBy10Pecrent()
theScale = theScale * 1.1
growIt(theScale)
end
function growIt(toThisScale)
transition.to(obj1,{…toThisScale,onComplete=growBy10Percent})
end
growIt(theScale)[/lua]
cheers,
?
[import]uid: 3826 topic_id: 12249 reply_id: 44630[/import]
I’ll try these. Thanks for the help.
Demetrius
[import]uid: 1380 topic_id: 12249 reply_id: 44631[/import]
I tried to do the same with parameters but it lead to error :
local Call\_trans1,Call\_trans2
function Call\_trans1(duration)
transition.to(obj1, {time=duration,...,onComplete=Call\_trans2(1000)})
end
function Call\_trans2(duration)
transition.to(obj1, {time=duration,...,onComplete=Call\_trans1(1000)})
end
Call\_trans1(1000)
Any hints ? [import]uid: 9328 topic_id: 12249 reply_id: 58584[/import]
because you cannot pass parameters the way you did.
use
... onComplete = function() Call\_trans2(1000) end})
and
... onComplete = function() Call\_trans1(1000) end})
what you are doing is passing the *Value* of the function rather than pass the function.
cheers,
?
[import]uid: 3826 topic_id: 12249 reply_id: 58585[/import]
Oops…
Thx for your blazing fast answer :)) [import]uid: 9328 topic_id: 12249 reply_id: 58587[/import]