radius changing while transition

Hello,

I want to execute this :

local c=display.newCircle(100,100,30) transition.to(c,{time=1000,x=300,path.radius=10})

but it don’t work.

The c.path’s type is a userData. I can modify it by a onStart or onComplete function, but not during the transition.

Why ?

How to do that (with a transition.to) ?

Thanks.

Modify xScale and yScale

transition.to(c,{time=1000,x=300,xScale=3,yScale=3})

Warning:If you’re planning to use physics this won’t work to change the body size.  Once the body is added its size if fixed.

I inspired from http://spiralcodestudio.com/corona-sdk-pro-tip-of-the-day-34/ to modify transition and allow to change radius without xScale or yScale.

local function transition\_PATH\_RADIUS\_SUPPORT(o,params)   if not params.radius then return transition.to(o,params) end // traditional transition      local r,rObject=params.radius,o.path.radius // the radius to aim and the original radius   params.radius=nil   local tab={object=o,r0=0} // I will make transition on that table   local mt={}   setmetatable(tab,mt) // I put metatable on tab to allow to change radius of circle      function mt.\_\_index(tbl,key)     if key=="radius" then return tab.r0 end // use only once, to init the process because "radius is not present on key-value of params. I return 0   end        function mt.\_\_newindex(tbl,key,value)     if key=="radius" then // the key "radius" is changing with the transition made on table "tab"       tab.r0=value // r0 is updated here       tbl["object"].path.radius=rObject+(r-rObject)\*value/r // I change the radius here     end   end      local function start()     transition.to(tab,{time=params.time,radius=r})   end   params.onStart=start      return transition.to(o,params) // caution : transition.cancel(o) don't stop the radius process. Use in transition.cancel(tab) in addition to transition.cancel(o) end local cc=display.newCircle(30,100,30) local tt=transition\_PATH\_RADIUS\_SUPPORT(cc,{time=5000,x=w-30,radius=80,transition=easing.inOutBack,}) //allow transition effect

** SEE SUBSEQUENT POST ABOUT PATH **

The thing is:

  1. Circles don’t have a radius field.

  2. Changing it won’t change the circles radius.

Actually, you are on to something, but you want to modify the circle’s path:

local tmp = display.newCircle( 100, 100, 40 ) print(tmp.path.radius) transition.to( tmp.path, { radius = 100 })

Here is a re-write of your original code:

local c=display.newCircle( 100, 100, 30 ) transition.to( c.path, {time = 1000, radius = 10 } ) transition.to( c, {time = 1000, x=300 } )

LOLL in 2 lines you resume my code xd

the transition with c.path.radius don’t work because of the double point.

The transition only modify the “nearest” variable, not at 2 lvl at a time.

Thanks you very much :smiley:

Modify xScale and yScale

transition.to(c,{time=1000,x=300,xScale=3,yScale=3})

Warning:If you’re planning to use physics this won’t work to change the body size.  Once the body is added its size if fixed.

I inspired from http://spiralcodestudio.com/corona-sdk-pro-tip-of-the-day-34/ to modify transition and allow to change radius without xScale or yScale.

local function transition\_PATH\_RADIUS\_SUPPORT(o,params)   if not params.radius then return transition.to(o,params) end // traditional transition      local r,rObject=params.radius,o.path.radius // the radius to aim and the original radius   params.radius=nil   local tab={object=o,r0=0} // I will make transition on that table   local mt={}   setmetatable(tab,mt) // I put metatable on tab to allow to change radius of circle      function mt.\_\_index(tbl,key)     if key=="radius" then return tab.r0 end // use only once, to init the process because "radius is not present on key-value of params. I return 0   end        function mt.\_\_newindex(tbl,key,value)     if key=="radius" then // the key "radius" is changing with the transition made on table "tab"       tab.r0=value // r0 is updated here       tbl["object"].path.radius=rObject+(r-rObject)\*value/r // I change the radius here     end   end      local function start()     transition.to(tab,{time=params.time,radius=r})   end   params.onStart=start      return transition.to(o,params) // caution : transition.cancel(o) don't stop the radius process. Use in transition.cancel(tab) in addition to transition.cancel(o) end local cc=display.newCircle(30,100,30) local tt=transition\_PATH\_RADIUS\_SUPPORT(cc,{time=5000,x=w-30,radius=80,transition=easing.inOutBack,}) //allow transition effect

** SEE SUBSEQUENT POST ABOUT PATH **

The thing is:

  1. Circles don’t have a radius field.

  2. Changing it won’t change the circles radius.

Actually, you are on to something, but you want to modify the circle’s path:

local tmp = display.newCircle( 100, 100, 40 ) print(tmp.path.radius) transition.to( tmp.path, { radius = 100 })

Here is a re-write of your original code:

local c=display.newCircle( 100, 100, 30 ) transition.to( c.path, {time = 1000, radius = 10 } ) transition.to( c, {time = 1000, x=300 } )

LOLL in 2 lines you resume my code xd

the transition with c.path.radius don’t work because of the double point.

The transition only modify the “nearest” variable, not at 2 lvl at a time.

Thanks you very much :smiley: